I've got a MacOS/X program that uses CoreAudio to do sound output. It works fine, but whenever I compile it, the compiler emits the "XXX is deprecated" warnings shown below.
My question is, how should I update/replace these function calls so that I get the same functionality but done in a non-deprecated way? I can't seem to find any documentation on what Apple wants me to do in this case.
[ 0%] Building CXX object CMakeFiles/myprogram.dir/MyProgram.cpp.o
/MyProgram.cpp:295:25: warning: 'AudioDeviceSetProperty' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
const OSStatus err = AudioDeviceSetProperty(cadi()->GetAudioDeviceID(), 0, 0, FALSE, kAudioDevicePropertyHogMode, sizeof(myPID), &myPID);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareDeprecated.h:855:1: note: 'AudioDeviceSetProperty' has been explicitly marked deprecated here
AudioDeviceSetProperty( AudioDeviceID inDevice,
^
/MyProgram.cpp:352:31: warning: 'AudioDeviceAddPropertyListener' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
const OSStatus err = AudioDeviceAddPropertyListener(deviceID, 0, false, kAudioDeviceProcessorOverload, PlaybackDevicePropertyChanged, NULL);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareDeprecated.h:884:1: note: 'AudioDeviceAddPropertyListener' has been explicitly marked deprecated here
AudioDeviceAddPropertyListener( AudioDeviceID inDevice,
^
/MyProgram.cpp:358:31: warning: 'AudioDeviceRemovePropertyListener' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
const OSStatus err = AudioDeviceRemovePropertyListener(deviceID, 0, false, kAudioDeviceProcessorOverload, PlaybackDevicePropertyChanged);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareDeprecated.h:911:1: note: 'AudioDeviceRemovePropertyListener' has been explicitly marked deprecated here
AudioDeviceRemovePropertyListener( AudioDeviceID inDevice,
^
/MyProgram.cpp:437:24: warning: 'AudioHardwareGetPropertyInfo' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
OSStatus osErr = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyPlugInForBundleID, &outSize, &outWritable);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareDeprecated.h:321:1: note: 'AudioHardwareGetPropertyInfo' has been explicitly marked deprecated here
AudioHardwareGetPropertyInfo( AudioHardwarePropertyID inPropertyID,
^
/MyProgram.cpp:450:18: warning: 'AudioHardwareGetProperty' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
osErr = AudioHardwareGetProperty(kAudioHardwarePropertyPlugInForBundleID, &outSize, &pluginAVT);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareDeprecated.h:342:1: note: 'AudioHardwareGetProperty' has been explicitly marked deprecated here
AudioHardwareGetProperty( AudioHardwarePropertyID inPropertyID,
^
/MyProgram.cpp:582:12: warning: 'AudioHardwareGetPropertyInfo' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
osErr = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyPlugInForBundleID, &outSize, &outWritable);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareDeprecated.h:321:1: note: 'AudioHardwareGetPropertyInfo' has been explicitly marked deprecated here
AudioHardwareGetPropertyInfo( AudioHardwarePropertyID inPropertyID,
^
/MyProgram.cpp:595:12: warning: 'AudioHardwareGetProperty' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
osErr = AudioHardwareGetProperty(kAudioHardwarePropertyPlugInForBundleID, &outSize, &pluginAVT);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareDeprecated.h:342:1: note: 'AudioHardwareGetProperty' has been explicitly marked deprecated here
AudioHardwareGetProperty( AudioHardwarePropertyID inPropertyID,
^
If you go to the definitions of the functions in AudioHardwareDeprecated.h
you will find alternatives mentioned in the documentation.
Take AudioDeviceSetProperty()
For example:
Also note that the same functionality is provided by the function AudioObjectSetPropertyData().
This result in the following replacements:
AudioDeviceSetProperty()
Replace with AudioObjectSetPropertyData()
AudioDeviceAddPropertyListener()
Replace with AudioObjectAddPropertyListener()
in conjunction with AudioObjectPropertyListenerProc
AudioDeviceRemovePropertyListener()
Replace with AudioObjectRemovePropertyListener()
in conjunction with AudioObjectPropertyListenerProc()
AudioHardwareGetPropertyInfo()
Replace with AudioObjectHasProperty()
, AudioObjectIsPropertySettable()
and AudioObjectGetPropertyDataSize()
AudioHardwareGetProperty()
Replace with AudioObjectGetPropertyData()