]> git.sesse.net Git - vlc/commitdiff
auhal: do not check if device 0 is alive
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Sat, 11 May 2013 18:14:48 +0000 (20:14 +0200)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Sat, 11 May 2013 18:14:48 +0000 (20:14 +0200)
It will fail in any way.

modules/audio_output/auhal.c

index 66340461dbef28c63e734688f1b17f92fe09f0c4..33ec18ee177fc12931936eac585f71c07d0a0794 100644 (file)
@@ -279,23 +279,23 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
 
     msg_Dbg(p_aout, "attempting to use device %i", p_sys->i_selected_dev);
 
-    /* Check if the desired device is alive and usable */
-    i_param_size = sizeof(b_alive);
-    AudioObjectPropertyAddress audioDeviceAliveAddress = { kAudioDevicePropertyDeviceIsAlive,
-                                              kAudioObjectPropertyScopeGlobal,
-                                              kAudioObjectPropertyElementMaster };
-    err = AudioObjectGetPropertyData(p_sys->i_selected_dev, &audioDeviceAliveAddress, 0, NULL, &i_param_size, &b_alive);
+    AudioObjectPropertyAddress audioDeviceAliveAddress = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+    if (p_sys->i_selected_dev > 0) {
+        /* Check if the desired device is alive and usable */
+        i_param_size = sizeof(b_alive);
+        err = AudioObjectGetPropertyData(p_sys->i_selected_dev, &audioDeviceAliveAddress, 0, NULL, &i_param_size, &b_alive);
+        if (err != noErr) {
+            /* Be tolerant, only give a warning here */
+            msg_Warn(p_aout, "could not check whether device [0x%x] is alive [%4.4s]",
+                     (unsigned int)p_sys->i_selected_dev, (char *)&err);
+            b_alive = false;
+        }
 
-    if (err != noErr) {
-        /* Be tolerant, only give a warning here */
-        msg_Warn(p_aout, "could not check whether device [0x%x] is alive [%4.4s]",
-                           (unsigned int)p_sys->i_selected_dev, (char *)&err);
-        b_alive = false;
+        if (!b_alive)
+            msg_Warn(p_aout, "selected audio device is not alive, switching to default device");
     }
 
     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 };