mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-24 20:48:52 +02:00
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
This commit is contained in:
parent
cb37cbe2fc
commit
14250ccc4f
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user