diff options
author | Alex Szpakowski <[email protected]> | 2015-11-13 20:11:12 -0400 |
---|---|---|
committer | Alex Szpakowski <[email protected]> | 2015-11-13 20:11:12 -0400 |
commit | 21c84bcd96a2e457b446e53d3287878e32fc77e0 (patch) | |
tree | bbf13eeaa98e8aae056baeae07c77e9f943bad34 /Alc/backends/coreaudio.c | |
parent | f903a7aa645c4f7a95914104d532ddd66c8ad232 (diff) |
Replace deprecated Carbon API calls with modern AudioComponent APIs in the CoreAudio backend.
This prevents a deprecation notice from being output to stdout when alcOpenDevice is called in Mac OS X 10.11.
The new API calls require Mac OS X 10.6 or newer.
Diffstat (limited to 'Alc/backends/coreaudio.c')
-rw-r--r-- | Alc/backends/coreaudio.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c index 43e881da..d9264217 100644 --- a/Alc/backends/coreaudio.c +++ b/Alc/backends/coreaudio.c @@ -137,8 +137,8 @@ static OSStatus ca_capture_callback(void *inRefCon, AudioUnitRenderActionFlags * static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName) { - ComponentDescription desc; - Component comp; + AudioComponentDescription desc; + AudioComponent comp; ca_data *data; OSStatus err; @@ -154,19 +154,19 @@ static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName) desc.componentFlags = 0; desc.componentFlagsMask = 0; - comp = FindNextComponent(NULL, &desc); + comp = AudioComponentFindNext(NULL, &desc); if(comp == NULL) { - ERR("FindNextComponent failed\n"); + ERR("AudioComponentFindNext failed\n"); return ALC_INVALID_VALUE; } data = calloc(1, sizeof(*data)); - err = OpenAComponent(comp, &data->audioUnit); + err = AudioComponentInstanceNew(comp, &data->audioUnit); if(err != noErr) { - ERR("OpenAComponent failed\n"); + ERR("AudioComponentInstanceNew failed\n"); free(data); return ALC_INVALID_VALUE; } @@ -176,7 +176,7 @@ static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName) if(err != noErr) { ERR("AudioUnitInitialize failed\n"); - CloseComponent(data->audioUnit); + AudioComponentInstanceDispose(data->audioUnit); free(data); return ALC_INVALID_VALUE; } @@ -191,7 +191,7 @@ static void ca_close_playback(ALCdevice *device) ca_data *data = (ca_data*)device->ExtraData; AudioUnitUninitialize(data->audioUnit); - CloseComponent(data->audioUnit); + AudioComponentInstanceDispose(data->audioUnit); free(data); device->ExtraData = NULL; @@ -374,12 +374,13 @@ static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName) AudioStreamBasicDescription hardwareFormat; // The hardware format AudioStreamBasicDescription outputFormat; // The AudioUnit output format AURenderCallbackStruct input; - ComponentDescription desc; + AudioComponentDescription desc; AudioDeviceID inputDevice; UInt32 outputFrameCount; UInt32 propertySize; + AudioObjectPropertyAddress propertyAddress; UInt32 enableIO; - Component comp; + AudioComponent comp; ca_data *data; OSStatus err; @@ -395,10 +396,10 @@ static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName) desc.componentFlagsMask = 0; // Search for component with given description - comp = FindNextComponent(NULL, &desc); + comp = AudioComponentFindNext(NULL, &desc); if(comp == NULL) { - ERR("FindNextComponent failed\n"); + ERR("AudioComponentFindNext failed\n"); return ALC_INVALID_VALUE; } @@ -406,10 +407,10 @@ static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName) device->ExtraData = data; // Open the component - err = OpenAComponent(comp, &data->audioUnit); + err = AudioComponentInstanceNew(comp, &data->audioUnit); if(err != noErr) { - ERR("OpenAComponent failed\n"); + ERR("AudioComponentInstanceNew failed\n"); goto error; } @@ -432,11 +433,16 @@ static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName) } // Get the default input device + propertySize = sizeof(AudioDeviceID); - err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propertySize, &inputDevice); + propertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice; + propertyAddress.mScope = kAudioObjectPropertyScopeGlobal; + propertyAddress.mElement = kAudioObjectPropertyElementMaster; + + err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propertySize, &inputDevice); if(err != noErr) { - ERR("AudioHardwareGetProperty failed\n"); + ERR("AudioObjectGetPropertyData failed\n"); goto error; } @@ -596,7 +602,7 @@ error: if(data->audioConverter) AudioConverterDispose(data->audioConverter); if(data->audioUnit) - CloseComponent(data->audioUnit); + AudioComponentInstanceDispose(data->audioUnit); free(data); device->ExtraData = NULL; @@ -613,7 +619,7 @@ static void ca_close_capture(ALCdevice *device) destroy_buffer_list(data->bufferList); AudioConverterDispose(data->audioConverter); - CloseComponent(data->audioUnit); + AudioComponentInstanceDispose(data->audioUnit); free(data); device->ExtraData = NULL; |