]> git.sesse.net Git - vlc/commitdiff
auhal: fix device setup when no spidf available
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Fri, 5 Apr 2013 18:36:09 +0000 (20:36 +0200)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Fri, 5 Apr 2013 19:00:36 +0000 (21:00 +0200)
refs #8286

modules/audio_output/auhal.c

index 462b14d3985c801813cb7f9f72abd77ada2b64ab..b520dc61b273a7cad70e7a5e8aaf811607b607a3 100644 (file)
@@ -233,6 +233,8 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
      * property size */
     int                     b_alive = false;
 
+    bool                    b_start_digital = false;
+
     p_sys = p_aout->sys;
     p_sys->b_digital = false;
     p_sys->au_component = NULL;
@@ -247,9 +249,6 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
 
     aout_FormatPrint(p_aout, "VLC is looking for:", fmt);
 
-    if (p_sys->b_selected_dev_is_digital)
-        msg_Dbg(p_aout, "audio device supports digital output");
-
     msg_Dbg(p_aout, "attempting to use device %i", p_sys->i_selected_dev);
 
     /* Check if the desired device is alive and usable */
@@ -267,10 +266,19 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
     }
 
     if (!b_alive) {
-        msg_Warn(p_aout, "selected audio device is not alive, switching to default device");
+        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;
     }
 
+    // recheck if device still supports digital
+    b_start_digital = p_sys->b_selected_dev_is_digital;
+    if(!AudioDeviceSupportsDigital(p_aout, p_sys->i_selected_dev))
+        b_start_digital = false;
+
+    if (b_start_digital)
+        msg_Dbg(p_aout, "Use audio device for digital output");
+
     /* add a callback to see if the device dies later on */
     err = AudioObjectAddPropertyListener(p_sys->i_selected_dev, &audioDeviceAliveAddress, HardwareListener, (void *)p_aout);
     if (err != noErr) {
@@ -302,7 +310,7 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
     bool b_success = false;
 
     /* Check for Digital mode or Analog output mode */
-    if (AOUT_FMT_SPDIF (fmt) && p_sys->b_selected_dev_is_digital) {
+    if (AOUT_FMT_SPDIF (fmt) && b_start_digital) {
         if (StartSPDIF (p_aout, fmt)) {
             msg_Dbg(p_aout, "digital output successfully opened");
             b_success = true;