changeset 3699:4160ba33b597

Removed test for "driver is valid, but doesn't see any audio devices." It was causing problems, and it really doesn't make sense to do it that way. Fixes Bugzilla #834.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 26 Jan 2010 06:01:33 +0000
parents 17376128fb56
children 076c12750bc4
files src/audio/SDL_audio.c src/audio/alsa/SDL_alsa_audio.c src/audio/arts/SDL_artsaudio.c src/audio/baudio/SDL_beaudio.cc src/audio/bsd/SDL_bsdaudio.c src/audio/disk/SDL_diskaudio.c src/audio/dma/SDL_dmaaudio.c src/audio/dmedia/SDL_irixaudio.c src/audio/dsp/SDL_dspaudio.c src/audio/dummy/SDL_dummyaudio.c src/audio/esd/SDL_esdaudio.c src/audio/fusionsound/SDL_fsaudio.c src/audio/iphoneos/SDL_coreaudio_iphone.c src/audio/macosx/SDL_coreaudio.c src/audio/mme/SDL_mmeaudio.c src/audio/nas/SDL_nasaudio.c src/audio/nds/SDL_ndsaudio.c src/audio/paudio/SDL_paudio.c src/audio/pulseaudio/SDL_pulseaudio.c src/audio/qsa/SDL_qsa_audio.c src/audio/windib/SDL_dibaudio.c src/audio/windx5/SDL_dx5audio.c
diffstat 22 files changed, 26 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/src/audio/SDL_audio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/SDL_audio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -581,8 +581,6 @@
     int i = 0;
     int initialized = 0;
     int tried_to_init = 0;
-    int rc = 0;
-    int best_choice = -1;
 
     if (SDL_WasInit(SDL_INIT_AUDIO)) {
         SDL_AudioQuit();        /* shutdown driver if already running. */
@@ -608,34 +606,14 @@
         SDL_memset(&current_audio, 0, sizeof(current_audio));
         current_audio.name = backend->name;
         current_audio.desc = backend->desc;
-        rc = backend->init(&current_audio.impl);
-        if (rc == 2) {          /* init'd, and devices available. Take it! */
-            initialized = 1;
-            best_choice = i;
-        } else if (rc == 1) {   /* init'd, but can't see any devices. */
-            if (current_audio.impl.Deinitialize) {
-                current_audio.impl.Deinitialize();
-            }
-            if (best_choice == -1) {
-                best_choice = i;
-            }
-        }
-    }
-
-    /* No definite choice. Pick one that works but can't promise a device. */
-    if ((!initialized) && (best_choice != -1)) {
-        const AudioBootStrap *backend = bootstrap[best_choice];
-        SDL_memset(&current_audio, 0, sizeof(current_audio));
-        current_audio.name = backend->name;
-        current_audio.desc = backend->desc;
-        initialized = (backend->init(&current_audio.impl) > 0);
+        initialized = backend->init(&current_audio.impl);
     }
 
     if (!initialized) {
         /* specific drivers will set the error message if they fail... */
         if (!tried_to_init) {
             if (driver_name) {
-                SDL_SetError("%s not available", driver_name);
+                SDL_SetError("Audio target '%s' not available", driver_name);
             } else {
                 SDL_SetError("No available audio device");
             }
--- a/src/audio/alsa/SDL_alsa_audio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/alsa/SDL_alsa_audio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -681,7 +681,7 @@
     impl->Deinitialize = ALSA_Deinitialize;
     impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: Add device enum! */
 
-    return 1;                   /* !!! FIXME: return 2 once device enum is implemented. */
+    return 1;   /* this audio target is available. */
 }
 
 
--- a/src/audio/arts/SDL_artsaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/arts/SDL_artsaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -368,7 +368,7 @@
     impl->Deinitialize = ARTS_Deinitialize;
     impl->OnlyHasDefaultOutputDevice = 1;
 
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 
--- a/src/audio/baudio/SDL_beaudio.cc	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/baudio/SDL_beaudio.cc	Tue Jan 26 06:01:33 2010 +0000
@@ -204,7 +204,7 @@
     impl->ProvidesOwnCallbackThread = 1;
     impl->OnlyHasDefaultOutputDevice = 1;
 
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 extern "C"
--- a/src/audio/bsd/SDL_bsdaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/bsd/SDL_bsdaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -444,7 +444,8 @@
     impl->Deinitialize = BSDAUDIO_Deinitialize;
 
     build_device_lists();
-    return (outputDeviceCount > 0) ? 2 : 1;
+
+    return 1;   /* this audio target is available. */
 }
 
 
--- a/src/audio/disk/SDL_diskaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/disk/SDL_diskaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -158,7 +158,7 @@
     impl->GetDeviceBuf = DISKAUD_GetDeviceBuf;
     impl->CloseDevice = DISKAUD_CloseDevice;
 
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap DISKAUD_bootstrap = {
--- a/src/audio/dma/SDL_dmaaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/dma/SDL_dmaaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -524,7 +524,8 @@
     impl->Deinitialize = DMA_Deinitialize;
 
     build_device_lists();
-    return (outputDeviceCount > 0) ? 2 : 1;
+
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap DMA_bootstrap = {
--- a/src/audio/dmedia/SDL_irixaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/dmedia/SDL_irixaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -228,7 +228,7 @@
     impl->CloseDevice = DSP_CloseDevice;
     impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: not true, I think. */
 
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap IRIXAUDIO_bootstrap = {
--- a/src/audio/dsp/SDL_dspaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/dsp/SDL_dspaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -381,7 +381,8 @@
     impl->Deinitialize = DSP_Deinitialize;
 
     build_device_lists();
-    return (outputDeviceCount > 0) ? 2 : 1;
+
+    return 1;   /* this audio target is available. */
 }
 
 
--- a/src/audio/dummy/SDL_dummyaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/dummy/SDL_dummyaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -41,7 +41,7 @@
     /* Set the function pointers */
     impl->OpenDevice = DUMMYAUD_OpenDevice;
     impl->OnlyHasDefaultOutputDevice = 1;
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap DUMMYAUD_bootstrap = {
--- a/src/audio/esd/SDL_esdaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/esd/SDL_esdaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -341,7 +341,7 @@
     impl->Deinitialize = ESD_Deinitialize;
     impl->OnlyHasDefaultOutputDevice = 1;
 
-    return 2;                   /* return 2 (definitely have a "device"). */
+    return 1;   /* this audio target is available. */
 }
 
 
--- a/src/audio/fusionsound/SDL_fsaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/fusionsound/SDL_fsaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -340,7 +340,7 @@
     impl->Deinitialize = SDL_FS_Deinitialize;
     impl->OnlyHasDefaultOutputDevice = 1;
 
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 
--- a/src/audio/iphoneos/SDL_coreaudio_iphone.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/iphoneos/SDL_coreaudio_iphone.c	Tue Jan 26 06:01:33 2010 +0000
@@ -329,7 +329,7 @@
     impl->OnlyHasDefaultOutputDevice = 1;
     impl->HasCaptureSupport = 0;        /* still needs to be written */
 
-    return 2;                   /* defitely have an audio device. */
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap COREAUDIOIPHONE_bootstrap = {
--- a/src/audio/macosx/SDL_coreaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/macosx/SDL_coreaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -574,7 +574,7 @@
 
     build_device_lists();       /* do an initial check for devices... */
 
-    return (outputDeviceCount > 0) ? 2 : 1;
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap COREAUDIO_bootstrap = {
--- a/src/audio/mme/SDL_mmeaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/mme/SDL_mmeaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -249,7 +249,7 @@
     impl->CloseDevice = MME_CloseDevice;
     impl->OnlyHasDefaultOutputDevice = 1;
 
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 /* !!! FIXME: Windows "windib" driver is called waveout, too */
--- a/src/audio/nas/SDL_nasaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/nas/SDL_nasaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -398,7 +398,7 @@
     impl->Deinitialize = NAS_Deinitialize;
     impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: is this true? */
 
-    return 2;                   /* 2 == definitely has an audio device. */
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap NAS_bootstrap = {
--- a/src/audio/nds/SDL_ndsaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/nds/SDL_ndsaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -120,7 +120,7 @@
     impl->OnlyHasDefaultOutputDevice = 1;
     impl->OnlyHasDefaultInputDevice = 1;
 
-    return 2;                   /* 2 == definitely has an audio device. */
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap NDSAUD_bootstrap = {
--- a/src/audio/paudio/SDL_paudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/paudio/SDL_paudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -544,8 +544,7 @@
     impl->CloseDevice = DSP_CloseDevice;
     impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: add device enum! */
 
-    /* !!! FIXME: device enum might make this 1. */
-    return 2;                   /* 2 == definitely has an audio device. */
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap PAUDIO_bootstrap = {
--- a/src/audio/pulseaudio/SDL_pulseaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -529,8 +529,7 @@
     impl->Deinitialize = PULSEAUDIO_Deinitialize;
     impl->OnlyHasDefaultOutputDevice = 1;
 
-    /* !!! FIXME: should test if server is available here, return 2 if so. */
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 
--- a/src/audio/qsa/SDL_qsa_audio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/qsa/SDL_qsa_audio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -883,8 +883,7 @@
         return 1;
     }
 
-    /* At this point we are definitely has an audio device */
-    return 2;
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap QSAAUDIO_bootstrap = {
--- a/src/audio/windib/SDL_dibaudio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/windib/SDL_dibaudio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -327,8 +327,7 @@
     impl->CloseDevice = WINWAVEOUT_CloseDevice;
     impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: Is this true? */
 
-    /* !!! FIXME: not right for device enum? */
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap WINWAVEOUT_bootstrap = {
--- a/src/audio/windx5/SDL_dx5audio.c	Sun Jan 24 21:13:33 2010 +0000
+++ b/src/audio/windx5/SDL_dx5audio.c	Tue Jan 26 06:01:33 2010 +0000
@@ -508,8 +508,7 @@
     impl->Deinitialize = DSOUND_Deinitialize;
     impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME */
 
-    /* !!! FIXME: not right for device enum? */
-    return 1;
+    return 1;   /* this audio target is available. */
 }
 
 AudioBootStrap DSOUND_bootstrap = {