LONG
LONG

Reputation: 61

AudioHardwareServiceGetPropertyData deprecated

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?

Upvotes: 6

Views: 1658

Answers (1)

Tommy
Tommy

Reputation: 100632

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

Upvotes: 7

Related Questions