Skip to content

Commit

Permalink
Merge pull request #19106 from SaracenOne/audio_mic
Browse files Browse the repository at this point in the history
[WIP] Experimental microphone support
  • Loading branch information
akien-mga authored Aug 11, 2018
2 parents b6b1d14 + 7363695 commit 73cf0fd
Show file tree
Hide file tree
Showing 11 changed files with 1,243 additions and 311 deletions.
304 changes: 224 additions & 80 deletions drivers/coreaudio/audio_driver_coreaudio.cpp

Large diffs are not rendered by default.

36 changes: 30 additions & 6 deletions drivers/coreaudio/audio_driver_coreaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,24 @@ class AudioDriverCoreAudio : public AudioDriver {
Mutex *mutex;

String device_name;
String capture_device_name;

int mix_rate;
unsigned int channels;
unsigned int capture_channels;
unsigned int buffer_frames;
unsigned int buffer_size;

Vector<int32_t> samples_in;
Vector<int16_t> input_buf;

#ifdef OSX_ENABLED
Array _get_device_list(bool capture = false);
void _set_device(const String &device, bool capture = false);

static OSStatus input_device_address_cb(AudioObjectID inObjectID,
UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses,
void *inClientData);

static OSStatus output_device_address_cb(AudioObjectID inObjectID,
UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses,
void *inClientData);
Expand All @@ -68,6 +77,12 @@ class AudioDriverCoreAudio : public AudioDriver {
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData);

static OSStatus input_callback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData);

public:
const char *get_name() const {
return "CoreAudio";
Expand All @@ -77,18 +92,27 @@ class AudioDriverCoreAudio : public AudioDriver {
virtual void start();
virtual int get_mix_rate() const;
virtual SpeakerMode get_speaker_mode() const;
#ifdef OSX_ENABLED
virtual Array get_device_list();
virtual String get_device();
virtual void set_device(String device);
#endif

virtual void lock();
virtual void unlock();
virtual void finish();

virtual Error capture_start();
virtual Error capture_stop();

bool try_lock();
void stop();

#ifdef OSX_ENABLED
virtual Array get_device_list();
virtual String get_device();
virtual void set_device(String device);

virtual Array capture_get_device_list();
virtual void capture_set_device(const String &p_name);
virtual String capture_get_device();
#endif

AudioDriverCoreAudio();
~AudioDriverCoreAudio();
};
Expand Down
Loading

0 comments on commit 73cf0fd

Please sign in to comment.