Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AudioHardwareServiceGetPropertyData deprecated

Tags:

core-audio

I'm testing the sound recording on Mac, by using the following code

OSStatus error;
AudioDeviceID deviceID = 0;

AudioObjectPropertyAddress propertyAddress;
UInt32 propertySize;
propertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
propertyAddress.mElement = 0;
propertySize = sizeof(AudioDeviceID);
error = AudioHardwareServiceGetPropertyData(kAudioObjectSystemObject,
                                            &propertyAddress,
                                            0,
                                            NULL,
                                            &propertySize,
                                            &deviceID);
if(error)
    return error;

propertyAddress.mSelector = kAudioDevicePropertyNominalSampleRate;
propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
propertyAddress.mElement = 0;
propertySize = sizeof(Float64);
error = AudioHardwareServiceGetPropertyData(deviceID,
                                            &propertyAddress,
                                            0,
                                            NULL,
                                            &propertySize,
                                            outSampleRate);

But Xcode gave me that the AudioHardwareService*** are deprecated from OS X 10.11.

I checked the Apple's API guide, but I can't find any replacement for these APIs.

I know it works, but all these warnings are so annoying. What should I do?

like image 561
LONG Avatar asked May 10 '16 08:05

LONG


1 Answers

In your case, simply substituting AudioObjectGetPropertyData for AudioHardwareServiceGetPropertyData should suffice; see TN2223.

like image 52
Tommy Avatar answered Jan 03 '23 00:01

Tommy