[vlc-commits] auhal: use kAudioObjectPropertyName instead of kAudioDevicePropertyDeviceName to retrieve the (potentially localized) device name

Felix Paul Kühne git at videolan.org
Tue Feb 19 19:24:41 CET 2013


vlc/vlc-2.0 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Feb 16 20:27:31 2013 +0100| [e553d8c4b35279195dd804c4409353eeb4b20fe5] | committer: David Fuhrmann

auhal: use kAudioObjectPropertyName instead of kAudioDevicePropertyDeviceName to retrieve the (potentially localized) device name

This is the endorsed API and behaves correctly with regard to string lengths
(cherry picked from commit 14250ccc4fab3f18b0270465e2d3a4fe78c0ebfb)
(cherry picked from commit dd4d8155806afb07d6095924030b8c78e85fca61)

Conflicts:
	configure.ac
	modules/audio_output/auhal.c

Signed-off-by: David Fuhrmann <david.fuhrmann at googlemail.com>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=e553d8c4b35279195dd804c4409353eeb4b20fe5
---

 configure.ac                 |    2 +-
 modules/audio_output/auhal.c |   24 +++++++++++++++++-------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index c177e72..65377ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3550,7 +3550,7 @@ if test "x${enable_macosx_audio}" != "xno" &&
 then
   AC_CHECK_HEADERS(CoreAudio/CoreAudio.h,
     [ VLC_ADD_PLUGIN([auhal])
-      VLC_ADD_LIBS([auhal],[-Wl,-framework,CoreAudio,-framework,AudioUnit,-framework,AudioToolbox,-framework,Carbon])
+      VLC_ADD_LIBS([auhal],[-Wl,-framework,CoreAudio,-framework,AudioUnit,-framework,AudioToolbox,-framework,Carbon,-framework,CoreServices])
     ], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ])
 fi
 
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 2a73ebf..4ef7a94 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -1005,21 +1005,30 @@ static void Probe( audio_output_t * p_aout )
     text.psz_string = (char*)_("Audio Device");
     var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL );
 
-    AudioObjectPropertyAddress deviceNameAddress = { kAudioDevicePropertyDeviceName, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
+    AudioObjectPropertyAddress deviceNameAddress = { kAudioObjectPropertyName, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
 
     for( unsigned int i = 0; i < p_sys->i_devices; i++ )
     {
+        CFStringRef device_name_ref;
         char *psz_name;
-        i_param_size = 0;
+        CFIndex length;
+
 
         /* Retrieve the length of the device name */
         err = AudioObjectGetPropertyDataSize( p_devices[i], &deviceNameAddress, 0, NULL, &i_param_size );
-        if( err ) goto error;
+        if (err != noErr) {
+            goto error;
+        }
 
         /* Retrieve the name of the device */
-        psz_name = (char *)malloc( i_param_size );
-        err = AudioObjectGetPropertyData( p_devices[i], &deviceNameAddress, 0, NULL, &i_param_size, psz_name );
-        if( err ) goto error;
+        err = AudioObjectGetPropertyData( p_devices[i], &deviceNameAddress, 0, NULL, &i_param_size, &device_name_ref );
+        if (err != noErr) {
+            goto error;
+        }
+        length = CFStringGetLength(device_name_ref);
+        length++;
+        psz_name = (char *)malloc(length);
+        CFStringGetCString(device_name_ref, psz_name, length, kCFStringEncodingUTF8);
 
         msg_Dbg( p_aout, "DevID: %u DevName: %s", (unsigned)p_devices[i], psz_name );
 
@@ -1060,7 +1069,8 @@ static void Probe( audio_output_t * p_aout )
             }
         }
 
-        free( psz_name);
+        CFRelease(device_name_ref);
+        free(psz_name);
     }
 
     /* If a device is already "preselected", then use this device */



More information about the vlc-commits mailing list