[vlc-commits] auhal: use kAudioObjectPropertyName instead of kAudioDevicePropertyDeviceName to retrieve the (potentially localized) device name
Felix Paul Kühne
git at videolan.org
Sat Feb 16 20:35:16 CET 2013
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Feb 16 20:27:31 2013 +0100| [14250ccc4fab3f18b0270465e2d3a4fe78c0ebfb] | committer: Felix Paul Kühne
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
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=14250ccc4fab3f18b0270465e2d3a4fe78c0ebfb
---
configure.ac | 2 +-
modules/audio_output/auhal.c | 19 +++++++++----------
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
index 238de73..3529313 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index d45770a..d3ba347 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -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);
}
More information about the vlc-commits
mailing list