]> git.sesse.net Git - vlc/commitdiff
auhal: use kAudioObjectPropertyName instead of kAudioDevicePropertyDeviceName to...
authorFelix Paul Kühne <fkuehne@videolan.org>
Sat, 16 Feb 2013 19:27:31 +0000 (20:27 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sat, 16 Feb 2013 19:34:53 +0000 (20:34 +0100)
This is the endorsed API and behaves correctly with regard to string lengths

configure.ac
modules/audio_output/auhal.c

index 238de73ac24da9481e873a4410dfd52fb95fb76f..3529313e6bd23fc19120971f7e46477ac6369212 100644 (file)
@@ -3475,7 +3475,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])
+      VLC_ADD_LIBS([auhal],[-Wl,-framework,CoreAudio,-framework,AudioUnit,-framework,AudioToolbox,-framework,CoreServices])
     ], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ])
 fi
 
index d45770a2141038e0c50e8a421622c024e35d1e43..d3ba347a65241077dceaa0d6cc48f41b20b3ce76 100644 (file)
@@ -983,27 +983,25 @@ static void RebuildDeviceList(audio_output_t * p_aout)
     }
     p_sys->i_default_dev = defaultDeviceID;
 
-    AudioObjectPropertyAddress deviceNameAddress = { kAudioDevicePropertyDeviceName, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+    AudioObjectPropertyAddress deviceNameAddress = { kAudioObjectPropertyName, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
 
     for (unsigned int i = 0; i < numberOfDevices; i++) {
+        CFStringRef device_name_ref;
         char *psz_name;
+        CFIndex length;
         bool b_digital = false;
         UInt32 i_id = deviceIDs[i];
 
-        /* Retrieve the length of the device name */
-        err = AudioObjectGetPropertyDataSize(deviceIDs[i], &deviceNameAddress, 0, NULL, &propertySize);
-        if (err != noErr) {
-            msg_Dbg(p_aout, "failed to get name size for device %i", deviceIDs[i]);
-            continue;
-        }
-
         /* Retrieve the name of the device */
-        psz_name = (char *)malloc(propertySize);
-        err = AudioObjectGetPropertyData(deviceIDs[i], &deviceNameAddress, 0, NULL, &propertySize, psz_name);
+        err = AudioObjectGetPropertyData(deviceIDs[i], &deviceNameAddress, 0, NULL, &propertySize, &device_name_ref);
         if (err != noErr) {
             msg_Dbg(p_aout, "failed to get name for device %i", deviceIDs[i]);
             continue;
         }
+        length = CFStringGetLength(device_name_ref);
+        length++;
+        psz_name = (char *)malloc(length);
+        CFStringGetCString(device_name_ref, psz_name, length, kCFStringEncodingUTF8);
 
         msg_Dbg(p_aout, "DevID: %i DevName: %s", deviceIDs[i], psz_name);
 
@@ -1023,6 +1021,7 @@ static void RebuildDeviceList(audio_output_t * p_aout)
             add_device_to_list(p_aout, i_id, psz_name);
         }
 
+        CFRelease(device_name_ref);
         free(psz_name);
     }