CoreAudio: underflow test passes

This commit is contained in:
Andrew Kelley 2015-08-07 13:11:34 -07:00
parent c263a29b52
commit cdb02e2b46
2 changed files with 34 additions and 1 deletions

View file

@ -251,7 +251,6 @@ view `coverage/index.html` in a browser.
0. implement CoreAudio (OSX) backend, get examples working
- microphone example
- underflow example
0. ALSA backend for microphone example is broken
0. Add some builtin channel layouts from
https://developer.apple.com/library/mac/documentation/MusicAudio/Reference/CoreAudioDataTypesRef/#//apple_ref/doc/constant_group/Audio_Channel_Layout_Tags

View file

@ -839,8 +839,29 @@ static void device_thread_run(void *arg) {
}
}
static OSStatus on_device_overload(AudioObjectID in_object_id, UInt32 in_number_addresses,
const AudioObjectPropertyAddress in_addresses[], void *in_client_data)
{
SoundIoOutStreamPrivate *os = (SoundIoOutStreamPrivate *)in_client_data;
SoundIoOutStream *outstream = &os->pub;
outstream->underflow_callback(outstream);
return noErr;
}
static void outstream_destroy_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
SoundIoOutStreamCoreAudio *osca = &os->backend_data.coreaudio;
SoundIoOutStream *outstream = &os->pub;
SoundIoDevice *device = outstream->device;
SoundIoDevicePrivate *dev = (SoundIoDevicePrivate *)device;
SoundIoDeviceCoreAudio *dca = &dev->backend_data.coreaudio;
AudioObjectPropertyAddress prop_address = {
kAudioDeviceProcessorOverload,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
AudioObjectRemovePropertyListener(dca->device_id, &prop_address, on_device_overload, os);
if (osca->output_instance) {
AudioOutputUnitStop(osca->output_instance);
AudioComponentInstanceDispose(osca->output_instance);
@ -928,6 +949,19 @@ static int outstream_open_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamP
return SoundIoErrorOpeningDevice;
}
AudioObjectPropertyAddress prop_address = {
kAudioDeviceProcessorOverload,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
if ((os_err = AudioObjectAddPropertyListener(dca->device_id, &prop_address,
on_device_overload, os)))
{
outstream_destroy_ca(si, os);
return SoundIoErrorOpeningDevice;
}
return 0;
}