[PATCH] winecoreaudio: Fix deprecation warnings.

Charles Davis cdavis at mymail.mines.edu
Wed Jan 26 12:26:39 CST 2011


Also, don't use the Component Manager on 10.6. Apple has threatened to
rip it out, and it's already been replaced on Snow Leopard. It's
probably safe to assume that at some point (maybe even in the upcoming
10.7 "Lion" release) the Component Manager functions will be marked
__attribute__((deprecated)) as well.
---
 configure.ac                       |   15 +++++-
 dlls/winecoreaudio.drv/audio.c     |   34 ++++++++++---
 dlls/winecoreaudio.drv/audiounit.c |   78 +++++++++++++++++++++++++++--
 dlls/winecoreaudio.drv/mixer.c     |   97 ++++++++++++++++++++++++-----------
 4 files changed, 179 insertions(+), 45 deletions(-)

diff --git a/configure.ac b/configure.ac
index ed4cb43..5523d87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -371,6 +371,7 @@ AC_CHECK_HEADERS(\
 	ApplicationServices/ApplicationServices.h \
 	AudioToolbox/AudioConverter.h \
 	AudioUnit/AudioUnit.h \
+	AudioUnit/AudioComponent.h \
 	CL/cl.h \
 	Carbon/Carbon.h \
 	CoreAudio/CoreAudio.h \
@@ -711,8 +712,18 @@ case $host_os in
     fi
     if test "$ac_cv_header_CoreAudio_CoreAudio_h" = "yes" -a "$ac_cv_header_AudioUnit_AudioUnit_h" = "yes"
     then
-        dnl CoreServices needed by AudioUnit
-        AC_SUBST(COREAUDIO,"-framework CoreAudio -framework AudioUnit -framework CoreServices -framework AudioToolbox -framework CoreMIDI")
+        if test "$ac_cv_header_AudioUnit_AudioComponent_h" = "yes"
+        then
+            AC_SUBST(COREAUDIO,"-framework CoreFoundation -framework CoreAudio -framework AudioUnit -framework AudioToolbox -framework CoreMIDI")
+        else
+            dnl CoreServices needed by AudioUnit
+            AC_SUBST(COREAUDIO,"-framework CoreAudio -framework AudioUnit -framework CoreServices -framework AudioToolbox -framework CoreMIDI")
+        fi
+        dnl Check for the AUGraphAddNode function
+        ac_save_LIBS="$LIBS"
+        LIBS="$LIBS $COREAUDIO"
+        AC_CHECK_FUNCS(AUGraphAddNode)
+        LIBS="$ac_save_LIBS"
     fi
     if test "$ac_cv_header_OpenAL_al_h" = "yes"
     then
diff --git a/dlls/winecoreaudio.drv/audio.c b/dlls/winecoreaudio.drv/audio.c
index cf876ff..f543ca1 100644
--- a/dlls/winecoreaudio.drv/audio.c
+++ b/dlls/winecoreaudio.drv/audio.c
@@ -486,13 +486,17 @@ BOOL CoreAudio_GetDevCaps (void)
     OSStatus status;
     UInt32 propertySize;
     AudioDeviceID devId = CoreAudio_DefaultDevice.outputDeviceID;
+    AudioObjectPropertyAddress propertyAddress;
     
     char name[MAXPNAMELEN];
     
     propertySize = MAXPNAMELEN;
-    status = AudioDeviceGetProperty(devId, 0 , FALSE, kAudioDevicePropertyDeviceName, &propertySize, name);
+    propertyAddress.mSelector = kAudioDevicePropertyDeviceName;
+    propertyAddress.mScope = kAudioDevicePropertyScopeOutput;
+    propertyAddress.mElement = kAudioObjectPropertyElementMaster;
+    status = AudioObjectGetPropertyData(devId, &propertyAddress, 0, NULL, &propertySize, name);
     if (status) {
-        ERR("AudioHardwareGetProperty for kAudioDevicePropertyDeviceName return %s\n", wine_dbgstr_fourcc(status));
+        ERR("AudioObjectGetPropertyData for kAudioDevicePropertyDeviceName return %s\n", wine_dbgstr_fourcc(status));
         return FALSE;
     }
     
@@ -504,9 +508,18 @@ BOOL CoreAudio_GetDevCaps (void)
     memcpy(CoreAudio_DefaultDevice.dev_name, name, 32);
     
     propertySize = sizeof(CoreAudio_DefaultDevice.streamDescription);
-    status = AudioDeviceGetProperty(devId, 0, FALSE , kAudioDevicePropertyStreamFormat, &propertySize, &CoreAudio_DefaultDevice.streamDescription);
+    /* FIXME: kAudioDevicePropertyStreamFormat is deprecated. We're
+     * "supposed" to get an AudioStream object from the AudioDevice,
+     * then query it for the format with kAudioStreamPropertyVirtualFormat.
+     * Apple says that this is for our own good, because this property
+     * "has been shown to lead to programming mistakes by clients when
+     * working with devices with multiple streams." Only one problem:
+     * which stream? For now, just query the device.
+     */
+    propertyAddress.mSelector = kAudioDevicePropertyStreamFormat;
+    status = AudioObjectGetPropertyData(devId, &propertyAddress, 0, NULL, &propertySize, &CoreAudio_DefaultDevice.streamDescription);
     if (status != noErr) {
-        ERR("AudioHardwareGetProperty for kAudioDevicePropertyStreamFormat return %s\n", wine_dbgstr_fourcc(status));
+        ERR("AudioObjectGetPropertyData for kAudioDevicePropertyStreamFormat return %s\n", wine_dbgstr_fourcc(status));
         return FALSE;
     }
     
@@ -549,6 +562,7 @@ LONG CoreAudio_WaveInit(void)
 {
     OSStatus status;
     UInt32 propertySize;
+    AudioObjectPropertyAddress propertyAddress;
     int i;
     CFStringRef  messageThreadPortName;
     CFMessagePortRef port_ReceiveInMessageThread;
@@ -557,19 +571,23 @@ LONG CoreAudio_WaveInit(void)
     TRACE("()\n");
     
     /* number of sound cards */
-    AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propertySize, NULL);
+    propertyAddress.mSelector = kAudioHardwarePropertyDevices;
+    propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
+    propertyAddress.mElement = kAudioObjectPropertyElementMaster;
+    AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propertySize);
     propertySize /= sizeof(AudioDeviceID);
     TRACE("sound cards : %lu\n", propertySize);
     
     /* Get the output device */
     propertySize = sizeof(CoreAudio_DefaultDevice.outputDeviceID);
-    status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &propertySize, &CoreAudio_DefaultDevice.outputDeviceID);
+    propertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
+    status = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propertySize, &CoreAudio_DefaultDevice.outputDeviceID);
     if (status) {
-        ERR("AudioHardwareGetProperty return %s for kAudioHardwarePropertyDefaultOutputDevice\n", wine_dbgstr_fourcc(status));
+        ERR("AudioObjectGetPropertyData return %s for kAudioHardwarePropertyDefaultOutputDevice\n", wine_dbgstr_fourcc(status));
         return DRV_FAILURE;
     }
     if (CoreAudio_DefaultDevice.outputDeviceID == kAudioDeviceUnknown) {
-        ERR("AudioHardwareGetProperty: CoreAudio_DefaultDevice.outputDeviceID == kAudioDeviceUnknown\n");
+        ERR("AudioObjectGetPropertyData: CoreAudio_DefaultDevice.outputDeviceID == kAudioDeviceUnknown\n");
         return DRV_FAILURE;
     }
     
diff --git a/dlls/winecoreaudio.drv/audiounit.c b/dlls/winecoreaudio.drv/audiounit.c
index bef882b..5884411 100644
--- a/dlls/winecoreaudio.drv/audiounit.c
+++ b/dlls/winecoreaudio.drv/audiounit.c
@@ -68,8 +68,13 @@ extern OSStatus CoreAudio_wiAudioUnitIOProc(void *inRefCon,
 int AudioUnit_CreateDefaultAudioUnit(void *wwo, AudioUnit *au)
 {
     OSStatus err;
+#ifdef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
+    AudioComponent comp;
+    AudioComponentDescription desc;
+#else
     Component comp;
     ComponentDescription desc;
+#endif
     AURenderCallbackStruct callbackStruct;
 
     TRACE("\n");
@@ -80,11 +85,19 @@ int AudioUnit_CreateDefaultAudioUnit(void *wwo, AudioUnit *au)
     desc.componentFlags = 0;
     desc.componentFlagsMask = 0;
 
+#ifdef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
+    comp = AudioComponentFindNext(NULL, &desc);
+#else
     comp = FindNextComponent(NULL, &desc);
+#endif
     if (comp == NULL)
         return 0;
     
+#ifdef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
+    err = AudioComponentInstanceNew(comp, au);
+#else
     err = OpenAComponent(comp, au);
+#endif
     if (err != noErr || *au == NULL)
         return 0;
         
@@ -102,7 +115,12 @@ int AudioUnit_CreateDefaultAudioUnit(void *wwo, AudioUnit *au)
 
 int AudioUnit_CloseAudioUnit(AudioUnit au)
 {
-    OSStatus err = CloseComponent(au);
+    OSStatus err;
+#ifdef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
+    err = AudioComponentInstanceDispose(au);
+#else
+    err = CloseComponent(au);
+#endif
     return (err == noErr);
 }
 
@@ -170,11 +188,15 @@ int AudioUnit_GetInputDeviceSampleRate(void)
 {
     AudioDeviceID               defaultInputDevice;
     UInt32                      param;
+    AudioObjectPropertyAddress  propertyAddress;
     Float64                     sampleRate;
     OSStatus                    err;
 
     param = sizeof(defaultInputDevice);
-    err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &param, &defaultInputDevice);
+    propertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
+    propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
+    propertyAddress.mElement = kAudioObjectPropertyElementMaster;
+    err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &param, &defaultInputDevice);
     if (err != noErr || defaultInputDevice == kAudioDeviceUnknown)
     {
         ERR("Couldn't get the default audio input device ID: %08lx\n", err);
@@ -182,7 +204,9 @@ int AudioUnit_GetInputDeviceSampleRate(void)
     }
 
     param = sizeof(sampleRate);
-    err = AudioDeviceGetProperty(defaultInputDevice, 0, 1, kAudioDevicePropertyNominalSampleRate, &param, &sampleRate);
+    propertyAddress.mSelector = kAudioDevicePropertyNominalSampleRate;
+    propertyAddress.mScope = kAudioDevicePropertyScopeInput;
+    err = AudioObjectGetPropertyData(defaultInputDevice, &propertyAddress, 0, NULL, &param, &sampleRate);
     if (err != noErr)
     {
         ERR("Couldn't get the device sample rate: %08lx\n", err);
@@ -198,10 +222,19 @@ int AudioUnit_CreateInputUnit(void* wwi, AudioUnit* out_au,
         UInt32* outFrameCount)
 {
     OSStatus                    err = noErr;
+#ifdef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
+    /* Apple has threatened to rip out the Component Manager.
+     * Protect ourselves from that.
+     */
+    AudioComponentDescription   description;
+    AudioComponent              component;
+#else
     ComponentDescription        description;
     Component                   component;
+#endif
     AudioUnit                   au;
     UInt32                      param;
+    AudioObjectPropertyAddress  propertyAddress;
     AURenderCallbackStruct      callback;
     AudioDeviceID               defaultInputDevice;
     AudioStreamBasicDescription desiredFormat;
@@ -220,14 +253,22 @@ int AudioUnit_CreateInputUnit(void* wwi, AudioUnit* out_au,
     description.componentFlags          = 0;
     description.componentFlagsMask      = 0;
 
+#ifdef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
+    component = AudioComponentFindNext(NULL, &description);
+#else
     component = FindNextComponent(NULL, &description);
+#endif
     if (!component)
     {
         ERR("FindNextComponent(kAudioUnitSubType_HALOutput) failed\n");
         return 0;
     }
 
+#ifdef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
+    err = AudioComponentInstanceNew(component, &au);
+#else
     err = OpenAComponent(component, &au);
+#endif
     if (err != noErr || au == NULL)
     {
         ERR("OpenAComponent failed: %08lx\n", err);
@@ -267,7 +308,10 @@ int AudioUnit_CreateInputUnit(void* wwi, AudioUnit* out_au,
 
     /* Find the default input device */
     param = sizeof(defaultInputDevice);
-    err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &param, &defaultInputDevice);
+    propertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
+    propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
+    propertyAddress.mElement = kAudioObjectPropertyElementMaster;
+    err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &param, &defaultInputDevice);
     if (err != noErr || defaultInputDevice == kAudioDeviceUnknown)
     {
         ERR("Couldn't get the default audio device ID: %08lx\n", err);
@@ -343,7 +387,13 @@ int AudioUnit_CreateInputUnit(void* wwi, AudioUnit* out_au,
 
 error:
     if (au)
+    {
+#ifdef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
+        AudioComponentInstanceDispose(au);
+#else
         CloseComponent(au);
+#endif
+    }
     return 0;
 }
 
@@ -353,7 +403,15 @@ error:
 int SynthUnit_CreateDefaultSynthUnit(AUGraph *graph, AudioUnit *synth)
 {
     OSStatus err;
+#if defined(HAVE_AUDIOUNIT_AUDIOCOMPONENT_H) && defined(HAVE_AUGRAPHADDNODE)
+    /* AUGraphAddNode() was changed to take one of these in 10.6.
+     * Presumably Apple wants to completely exorcise Carbon from Darwin.
+     * The structure is the same, by the way, only the name is different.
+     */
+    AudioComponentDescription desc;
+#else
     ComponentDescription desc;
+#endif
     AUNode synthNode;
     AUNode outNode;
 
@@ -372,7 +430,11 @@ int SynthUnit_CreateDefaultSynthUnit(AUGraph *graph, AudioUnit *synth)
     desc.componentType = kAudioUnitType_MusicDevice;
     desc.componentSubType = kAudioUnitSubType_DLSSynth;
 
+#ifdef HAVE_AUGRAPHADDNODE
+    err = AUGraphAddNode(*graph, &desc, &synthNode);
+#else
     err = AUGraphNewNode(*graph, &desc, 0, NULL, &synthNode);
+#endif
     if (err != noErr)
     {
         ERR_(midi)("AUGraphNewNode cannot create synthNode : %s\n", wine_dbgstr_fourcc(err));
@@ -383,7 +445,11 @@ int SynthUnit_CreateDefaultSynthUnit(AUGraph *graph, AudioUnit *synth)
     desc.componentType = kAudioUnitType_Output;
     desc.componentSubType = kAudioUnitSubType_DefaultOutput;
 
+#ifdef HAVE_AUGRAPHADDNODE
+    err = AUGraphAddNode(*graph, &desc, &outNode);
+#else
     err = AUGraphNewNode(*graph, &desc, 0, NULL, &outNode);
+#endif
     if (err != noErr)
     {
         ERR_(midi)("AUGraphNewNode cannot create outNode %s\n", wine_dbgstr_fourcc(err));
@@ -406,7 +472,11 @@ int SynthUnit_CreateDefaultSynthUnit(AUGraph *graph, AudioUnit *synth)
     }
 
     /* Get the synth unit */
+#ifdef HAVE_AUGRAPHADDNODE
+    err = AUGraphNodeInfo(*graph, synthNode, 0, synth);
+#else
     err = AUGraphGetNodeInfo(*graph, synthNode, 0, 0, 0, synth);
+#endif
     if (err != noErr)
     {
         ERR_(midi)("AUGraphGetNodeInfo return %s\n", wine_dbgstr_fourcc(err));
diff --git a/dlls/winecoreaudio.drv/mixer.c b/dlls/winecoreaudio.drv/mixer.c
index 389caad..1e9faef 100644
--- a/dlls/winecoreaudio.drv/mixer.c
+++ b/dlls/winecoreaudio.drv/mixer.c
@@ -214,11 +214,14 @@ static BOOL DeviceHasMute(AudioDeviceID deviceID, Boolean isInput)
 {
     Boolean writable = false;
     OSStatus err = noErr;
-    err = AudioDeviceGetPropertyInfo(deviceID, 0, isInput, kAudioDevicePropertyMute, NULL, NULL);
-    if (err == noErr)
+    AudioObjectPropertyAddress propertyAddress;
+    propertyAddress.mSelector = kAudioDevicePropertyMute;
+    propertyAddress.mScope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+    propertyAddress.mElement = 0;
+    if (AudioObjectHasProperty(deviceID, &propertyAddress))
     {
         /* check if we can set it */
-        err = AudioDeviceGetPropertyInfo(deviceID, 0, isInput, kAudioDevicePropertyMute, NULL, &writable);
+        err = AudioObjectIsPropertySettable(deviceID, &propertyAddress, &writable);
         if (err == noErr)
             return writable;
     }
@@ -233,16 +236,21 @@ static BOOL MIX_LineGetVolume(DWORD lineID, DWORD channels, Float32 *left, Float
     MixerLine *line = &mixer.lines[lineID];
     UInt32 size = sizeof(Float32);
     OSStatus err = noErr;
+    AudioObjectPropertyAddress address;
     *left = *right = 0.0;
 
-    err = AudioDeviceGetProperty(line->deviceID, 1, IsInput(line->direction), kAudioDevicePropertyVolumeScalar, &size, left);
+    address.mSelector = kAudioDevicePropertyVolumeScalar;
+    address.mScope = IsInput(line->direction) ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+    address.mElement = 1;
+    err = AudioObjectGetPropertyData(line->deviceID, &address, 0, NULL, &size, left);
     if (err != noErr)
         return FALSE;
 
     if (channels == 2)
     {
         size = sizeof(Float32);
-        err = AudioDeviceGetProperty(line->deviceID, 2, IsInput(line->direction), kAudioDevicePropertyVolumeScalar, &size, right);
+        address.mElement = 2;
+        err = AudioObjectGetPropertyData(line->deviceID, &address, 0, NULL, &size, right);
         if (err != noErr)
             return FALSE;
     }
@@ -257,7 +265,11 @@ static BOOL MIX_LineGetMute(DWORD lineID, BOOL *muted)
     UInt32 size = sizeof(UInt32);
     UInt32 val = 0;
     OSStatus err = noErr;
-    err = AudioDeviceGetProperty(line->deviceID, 0, IsInput(line->direction), kAudioDevicePropertyMute, &size, &val);
+    AudioObjectPropertyAddress address;
+    address.mSelector = kAudioDevicePropertyMute;
+    address.mScope = IsInput(line->direction) ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+    address.mElement = 0;
+    err = AudioObjectGetPropertyData(line->deviceID, &address, 0, NULL, &size, &val);
     *muted = val;
 
     return (err == noErr);
@@ -270,28 +282,36 @@ static BOOL MIX_LineSetVolume(DWORD lineID, DWORD channels, Float32 left, Float3
 {
     MixerLine *line = &mixer.lines[lineID];
     UInt32 size = sizeof(Float32);
+    AudioObjectPropertyAddress address;
     OSStatus err = noErr;
     TRACE("lineID %d channels %d left %f right %f\n", lineID, channels, left, right);
 
+    address.mSelector = kAudioDevicePropertyVolumeScalar;
+    address.mScope = IsInput(line->direction) ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
     if (channels == 2)
     {
-        err = AudioDeviceSetProperty(line->deviceID, NULL, 1, IsInput(line->direction), kAudioDevicePropertyVolumeScalar, size, &left);
+        address.mElement = 1;
+        err = AudioObjectSetPropertyData(line->deviceID, &address, 0, NULL, size, &left);
         if (err != noErr)
             return FALSE;
 
-        err = AudioDeviceSetProperty(line->deviceID, NULL, 2, IsInput(line->direction), kAudioDevicePropertyVolumeScalar, size, &right);
+        address.mElement = 2;
+        err = AudioObjectSetPropertyData(line->deviceID, &address, 0, NULL, size, &right);
     }
     else
     {
         /*
             FIXME Using master channel failed ?? return kAudioHardwareUnknownPropertyError
-            err = AudioDeviceSetProperty(line->deviceID, NULL, 0, IsInput(line->direction), kAudioDevicePropertyVolumeScalar, size, &left);
+            address.mElement = 0;
+            err = AudioObjectSetPropertyData(line->deviceID, &address, 0, NULL, size, &left);
         */
         right = left;
-        err = AudioDeviceSetProperty(line->deviceID, NULL, 1, IsInput(line->direction), kAudioDevicePropertyVolumeScalar, size, &left);
+        address.mElement = 1;
+        err = AudioObjectSetPropertyData(line->deviceID, &address, 0, NULL, size, &left);
         if (err != noErr)
             return FALSE;
-        err = AudioDeviceSetProperty(line->deviceID, NULL, 2, IsInput(line->direction), kAudioDevicePropertyVolumeScalar, size, &right);
+        address.mElement = 2;
+        err = AudioObjectSetPropertyData(line->deviceID, &address, 0, NULL, size, &right);
     }
     return (err == noErr);
 }
@@ -301,9 +321,13 @@ static BOOL MIX_LineSetMute(DWORD lineID, BOOL mute)
     MixerLine *line = &mixer.lines[lineID];
     UInt32 val = mute;
     UInt32 size = sizeof(UInt32);
+    AudioObjectPropertyAddress address;
     OSStatus err = noErr;
 
-    err = AudioDeviceSetProperty(line->deviceID, 0, 0, IsInput(line->direction), kAudioDevicePropertyMute, size, &val);
+    address.mSelector = kAudioDevicePropertyMute;
+    address.mScope = IsInput(line->direction) ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
+    address.mElement = 0;
+    err = AudioObjectSetPropertyData(line->deviceID, &address, 0, 0, size, &val);
     return (err == noErr);
 }
 
@@ -345,18 +369,22 @@ LONG CoreAudio_MixerInit(void)
 {
     OSStatus status;
     UInt32 propertySize;
+    AudioObjectPropertyAddress propertyAddress;
     AudioDeviceID *deviceArray = NULL;
-    char name[MAXPNAMELEN];
+    CFStringRef name;
     int i;
     int numLines;
 
     AudioStreamBasicDescription streamDescription;
 
     /* Find number of lines */
-    status = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propertySize, NULL);
+    propertyAddress.mSelector = kAudioHardwarePropertyDevices;
+    propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
+    propertyAddress.mElement = kAudioObjectPropertyElementMaster;
+    status = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propertySize);
     if (status)
     {
-        ERR("AudioHardwareGetPropertyInfo for kAudioHardwarePropertyDevices return %s\n", wine_dbgstr_fourcc(status));
+        ERR("AudioObjectGetPropertyDataSize for kAudioHardwarePropertyDevices return %s\n", wine_dbgstr_fourcc(status));
         return DRV_FAILURE;
     }
 
@@ -382,41 +410,45 @@ LONG CoreAudio_MixerInit(void)
     deviceArray = HeapAlloc(GetProcessHeap(), 0, sizeof(AudioDeviceID) * numLines);
 
     propertySize = sizeof(AudioDeviceID) * numLines;
-    status = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propertySize, deviceArray);
+    status = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propertySize, deviceArray);
     if (status)
     {
-        ERR("AudioHardwareGetProperty for kAudioHardwarePropertyDevices return %s\n", wine_dbgstr_fourcc(status));
+        ERR("AudioObjectGetPropertyData for kAudioHardwarePropertyDevices return %s\n", wine_dbgstr_fourcc(status));
         goto error;
     }
 
     for (i = 0; i < numLines; i++)
     {
-        Boolean write;
         MixerLine *line = &mixer.lines[i];
 
         line->deviceID = deviceArray[i];
 
-        propertySize = MAXPNAMELEN;
-        status = AudioDeviceGetProperty(line->deviceID, 0 , FALSE, kAudioDevicePropertyDeviceName, &propertySize, name);
+        propertySize = sizeof(CFStringRef);
+        propertyAddress.mSelector = kAudioObjectPropertyName;
+        propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
+        propertyAddress.mElement = kAudioObjectPropertyElementMaster;
+        status = AudioObjectGetPropertyData(line->deviceID, &propertyAddress, 0, NULL, &propertySize, &name);
         if (status) {
-            ERR("AudioHardwareGetProperty for kAudioDevicePropertyDeviceName return %s\n", wine_dbgstr_fourcc(status));
+            ERR("AudioObjectGetPropertyData for kAudioObjectPropertyName return %s\n", wine_dbgstr_fourcc(status));
             goto error;
         }
 
-        line->name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlen(name) + 1);
+        line->name = HeapAlloc(GetProcessHeap(), 0, CFStringGetLength(name) + 1);
         if (!line->name)
             goto error;
 
-        memcpy(line->name, name, strlen(name));
+        CFStringGetCString(name, line->name, CFStringGetLength(name) + 1, kCFStringEncodingUTF8);
 
         line->componentType = DeviceComponentType(line->name);
 
         /* check for directions */
         /* Output ? */
         propertySize = sizeof(UInt32);
-	status = AudioDeviceGetPropertyInfo(line->deviceID, 0, FALSE, kAudioDevicePropertyStreams, &propertySize, &write );
+        propertyAddress.mSelector = kAudioDevicePropertyStreams;
+        propertyAddress.mScope = kAudioDevicePropertyScopeOutput;
+	status = AudioObjectGetPropertyDataSize(line->deviceID, &propertyAddress, 0, NULL, &propertySize);
         if (status) {
-            ERR("AudioDeviceGetPropertyInfo for kAudioDevicePropertyDataSource return %s\n", wine_dbgstr_fourcc(status));
+            ERR("AudioObjectGetPropertyDataSize for kAudioDevicePropertyStreams return %s\n", wine_dbgstr_fourcc(status));
             goto error;
         }
 
@@ -426,9 +458,10 @@ LONG CoreAudio_MixerInit(void)
 
             /* Check the number of channel for the stream */
             propertySize = sizeof(streamDescription);
-            status = AudioDeviceGetProperty(line->deviceID, 0, FALSE , kAudioDevicePropertyStreamFormat, &propertySize, &streamDescription);
+            propertyAddress.mSelector = kAudioDevicePropertyStreamFormat;
+            status = AudioObjectGetPropertyData(line->deviceID, &propertyAddress, 0, NULL, &propertySize, &streamDescription);
             if (status != noErr) {
-                ERR("AudioHardwareGetProperty for kAudioDevicePropertyStreamFormat return %s\n", wine_dbgstr_fourcc(status));
+                ERR("AudioObjectGetPropertyData for kAudioDevicePropertyStreamFormat return %s\n", wine_dbgstr_fourcc(status));
                 goto error;
             }
             line->numChannels = streamDescription.mChannelsPerFrame;
@@ -437,9 +470,10 @@ LONG CoreAudio_MixerInit(void)
         {
             /* Input ? */
             propertySize = sizeof(UInt32);
-            status = AudioDeviceGetPropertyInfo(line->deviceID, 0, TRUE, kAudioDevicePropertyStreams, &propertySize, &write );
+            propertyAddress.mScope = kAudioDevicePropertyScopeInput;
+            status = AudioObjectGetPropertyDataSize(line->deviceID, &propertyAddress, 0, NULL, &propertySize);
             if (status) {
-                ERR("AudioDeviceGetPropertyInfo for kAudioDevicePropertyStreams return %s\n", wine_dbgstr_fourcc(status));
+                ERR("AudioObjectGetPropertyDataSize for kAudioDevicePropertyStreams return %s\n", wine_dbgstr_fourcc(status));
                 goto error;
             }
             if ( (propertySize / sizeof(AudioStreamID)) != 0)
@@ -448,9 +482,10 @@ LONG CoreAudio_MixerInit(void)
 
                 /* Check the number of channel for the stream */
                 propertySize = sizeof(streamDescription);
-                status = AudioDeviceGetProperty(line->deviceID, 0, TRUE, kAudioDevicePropertyStreamFormat, &propertySize, &streamDescription);
+                propertyAddress.mSelector = kAudioDevicePropertyStreamFormat;
+                status = AudioObjectGetPropertyData(line->deviceID, &propertyAddress, 0, NULL, &propertySize, &streamDescription);
                 if (status != noErr) {
-                    ERR("AudioHardwareGetProperty for kAudioDevicePropertyStreamFormat return %s\n", wine_dbgstr_fourcc(status));
+                    ERR("AudioObjectGetPropertyData for kAudioDevicePropertyStreamFormat return %s\n", wine_dbgstr_fourcc(status));
                     goto error;
                 }
                 line->numChannels = streamDescription.mChannelsPerFrame;
-- 
1.7.4.rc3




More information about the wine-patches mailing list