[vlc-commits] auhal: fix SPDIF -> default device fallback if SPDIF device is unplugged during playback ( close #8286)
Felix Paul Kühne
git at videolan.org
Thu Apr 25 12:42:37 CEST 2013
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu Apr 25 12:41:57 2013 +0200| [1cb158c9f4442fe52dc8c1ee7037c35aeabf4473] | committer: Felix Paul Kühne
auhal: fix SPDIF -> default device fallback if SPDIF device is unplugged during playback (close #8286)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1cb158c9f4442fe52dc8c1ee7037c35aeabf4473
---
modules/audio_output/auhal.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index efefeb7..2558de6 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -288,10 +288,22 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
b_alive = false;
}
- if (!b_alive) {
- msg_Warn(p_aout, "selected audio device is not alive, switching to default device with id %i", p_sys->i_default_dev);
- p_sys->i_selected_dev = p_sys->i_default_dev;
- p_sys->b_selected_dev_is_digital = false;
+ if (!b_alive || p_sys->i_selected_dev == 0) {
+ msg_Warn(p_aout, "selected audio device is not alive, switching to default device");
+
+ AudioObjectID defaultDeviceID = 0;
+ UInt32 propertySize = 0;
+ AudioObjectPropertyAddress defaultDeviceAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
+ propertySize = sizeof(AudioObjectID);
+ err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &defaultDeviceAddress, 0, NULL, &propertySize, &defaultDeviceID);
+ if (err != noErr) {
+ msg_Err(p_aout, "could not get default audio device [%4.4s]", (char *)&err);
+ goto error;
+ }
+ else
+ msg_Dbg(p_aout, "using default audio device %i", defaultDeviceID);
+
+ p_sys->i_selected_dev = defaultDeviceID;
}
// recheck if device still supports digital
@@ -966,7 +978,7 @@ static void Stop(audio_output_t *p_aout)
static void ReportDevice(audio_output_t *p_aout, UInt32 i_id, char *name)
{
- char deviceid[100];
+ char deviceid[10];
sprintf(deviceid, "%i", i_id);
aout_HotplugReport(p_aout, deviceid, name);
@@ -976,7 +988,6 @@ static void RebuildDeviceList(audio_output_t * p_aout)
{
OSStatus err = noErr;
UInt32 propertySize = 0;
- AudioObjectID defaultDeviceID = 0;
AudioObjectID *deviceIDs;
UInt32 numberOfDevices;
CFMutableArrayRef currentListOfDevices;
@@ -1014,16 +1025,6 @@ static void RebuildDeviceList(audio_output_t * p_aout)
return;
}
- /* Find the ID of the default Device */
- AudioObjectPropertyAddress defaultDeviceAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
- propertySize = sizeof(AudioObjectID);
- err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &defaultDeviceAddress, 0, NULL, &propertySize, &defaultDeviceID);
- if (err != noErr) {
- msg_Err(p_aout, "could not get default audio device [%4.4s]", (char *)&err);
- return;
- }
- p_sys->i_default_dev = defaultDeviceID;
-
AudioObjectPropertyAddress deviceNameAddress = { kAudioObjectPropertyName, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
for (unsigned int i = 0; i < numberOfDevices; i++) {
@@ -1085,8 +1086,6 @@ static void RebuildDeviceList(audio_output_t * p_aout)
count = CFArrayGetCount(p_sys->device_list);
if (count > 0) {
- CFShow(currentListOfDevices);
- CFShow(p_sys->device_list);
CFNumberRef cfn_device_id;
int i_device_id = 0;
for (CFIndex x = 0; x < count; x++) {
More information about the vlc-commits
mailing list