Sfoglia il codice sorgente

audio: take first reported device if no default was specified.

Ryan C. Gordon 1 anno fa
parent
commit
b60a56d368
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      src/audio/SDL_audio.c

+ 7 - 1
src/audio/SDL_audio.c

@@ -579,7 +579,13 @@ int SDL_InitAudio(const char *driver_name)
         current_audio.default_capture_device_id = default_capture->instance_id;
     }
 
-    // !!! FIXME: if a default is zero but there are devices available, should we just pick the first one?
+    // If no default was _ever_ specified, just take the first device we see, if any.
+    if (!current_audio.default_output_device_id && (current_audio.output_devices != NULL)) {
+        current_audio.default_output_device_id = current_audio.output_devices->instance_id;
+    }
+    if (!current_audio.default_capture_device_id && (current_audio.capture_devices != NULL)) {
+        current_audio.default_capture_device_id = current_audio.capture_devices->instance_id;
+    }
 
     return 0;
 }