Commit 14250ccc authored by Felix Paul Kühne's avatar Felix Paul Kühne

auhal: use kAudioObjectPropertyName instead of kAudioDevicePropertyDeviceName...

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
parent cb37cbe2
...@@ -3475,7 +3475,7 @@ if test "x${enable_macosx_audio}" != "xno" && ...@@ -3475,7 +3475,7 @@ if test "x${enable_macosx_audio}" != "xno" &&
then then
AC_CHECK_HEADERS(CoreAudio/CoreAudio.h, AC_CHECK_HEADERS(CoreAudio/CoreAudio.h,
[ VLC_ADD_PLUGIN([auhal]) [ 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]) ]) ], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ])
fi fi
......
...@@ -983,27 +983,25 @@ static void RebuildDeviceList(audio_output_t * p_aout) ...@@ -983,27 +983,25 @@ static void RebuildDeviceList(audio_output_t * p_aout)
} }
p_sys->i_default_dev = defaultDeviceID; p_sys->i_default_dev = defaultDeviceID;
AudioObjectPropertyAddress deviceNameAddress = { kAudioDevicePropertyDeviceName, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectPropertyAddress deviceNameAddress = { kAudioObjectPropertyName, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
for (unsigned int i = 0; i < numberOfDevices; i++) { for (unsigned int i = 0; i < numberOfDevices; i++) {
CFStringRef device_name_ref;
char *psz_name; char *psz_name;
CFIndex length;
bool b_digital = false; bool b_digital = false;
UInt32 i_id = deviceIDs[i]; 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 */ /* Retrieve the name of the device */
psz_name = (char *)malloc(propertySize); err = AudioObjectGetPropertyData(deviceIDs[i], &deviceNameAddress, 0, NULL, &propertySize, &device_name_ref);
err = AudioObjectGetPropertyData(deviceIDs[i], &deviceNameAddress, 0, NULL, &propertySize, psz_name);
if (err != noErr) { if (err != noErr) {
msg_Dbg(p_aout, "failed to get name for device %i", deviceIDs[i]); msg_Dbg(p_aout, "failed to get name for device %i", deviceIDs[i]);
continue; 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); msg_Dbg(p_aout, "DevID: %i DevName: %s", deviceIDs[i], psz_name);
...@@ -1023,6 +1021,7 @@ static void RebuildDeviceList(audio_output_t * p_aout) ...@@ -1023,6 +1021,7 @@ static void RebuildDeviceList(audio_output_t * p_aout)
add_device_to_list(p_aout, i_id, psz_name); add_device_to_list(p_aout, i_id, psz_name);
} }
CFRelease(device_name_ref);
free(psz_name); free(psz_name);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment