Removed test for "driver is valid, but doesn't see any audio devices."
authorRyan C. Gordon <icculus@icculus.org>
Tue, 26 Jan 2010 06:01:33 +0000
changeset 36994160ba33b597
parent 3698 17376128fb56
child 3700 076c12750bc4
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.
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
     1.1 --- a/src/audio/SDL_audio.c	Sun Jan 24 21:13:33 2010 +0000
     1.2 +++ b/src/audio/SDL_audio.c	Tue Jan 26 06:01:33 2010 +0000
     1.3 @@ -581,8 +581,6 @@
     1.4      int i = 0;
     1.5      int initialized = 0;
     1.6      int tried_to_init = 0;
     1.7 -    int rc = 0;
     1.8 -    int best_choice = -1;
     1.9  
    1.10      if (SDL_WasInit(SDL_INIT_AUDIO)) {
    1.11          SDL_AudioQuit();        /* shutdown driver if already running. */
    1.12 @@ -608,34 +606,14 @@
    1.13          SDL_memset(&current_audio, 0, sizeof(current_audio));
    1.14          current_audio.name = backend->name;
    1.15          current_audio.desc = backend->desc;
    1.16 -        rc = backend->init(&current_audio.impl);
    1.17 -        if (rc == 2) {          /* init'd, and devices available. Take it! */
    1.18 -            initialized = 1;
    1.19 -            best_choice = i;
    1.20 -        } else if (rc == 1) {   /* init'd, but can't see any devices. */
    1.21 -            if (current_audio.impl.Deinitialize) {
    1.22 -                current_audio.impl.Deinitialize();
    1.23 -            }
    1.24 -            if (best_choice == -1) {
    1.25 -                best_choice = i;
    1.26 -            }
    1.27 -        }
    1.28 -    }
    1.29 -
    1.30 -    /* No definite choice. Pick one that works but can't promise a device. */
    1.31 -    if ((!initialized) && (best_choice != -1)) {
    1.32 -        const AudioBootStrap *backend = bootstrap[best_choice];
    1.33 -        SDL_memset(&current_audio, 0, sizeof(current_audio));
    1.34 -        current_audio.name = backend->name;
    1.35 -        current_audio.desc = backend->desc;
    1.36 -        initialized = (backend->init(&current_audio.impl) > 0);
    1.37 +        initialized = backend->init(&current_audio.impl);
    1.38      }
    1.39  
    1.40      if (!initialized) {
    1.41          /* specific drivers will set the error message if they fail... */
    1.42          if (!tried_to_init) {
    1.43              if (driver_name) {
    1.44 -                SDL_SetError("%s not available", driver_name);
    1.45 +                SDL_SetError("Audio target '%s' not available", driver_name);
    1.46              } else {
    1.47                  SDL_SetError("No available audio device");
    1.48              }
     2.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Sun Jan 24 21:13:33 2010 +0000
     2.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Tue Jan 26 06:01:33 2010 +0000
     2.3 @@ -681,7 +681,7 @@
     2.4      impl->Deinitialize = ALSA_Deinitialize;
     2.5      impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: Add device enum! */
     2.6  
     2.7 -    return 1;                   /* !!! FIXME: return 2 once device enum is implemented. */
     2.8 +    return 1;   /* this audio target is available. */
     2.9  }
    2.10  
    2.11  
     3.1 --- a/src/audio/arts/SDL_artsaudio.c	Sun Jan 24 21:13:33 2010 +0000
     3.2 +++ b/src/audio/arts/SDL_artsaudio.c	Tue Jan 26 06:01:33 2010 +0000
     3.3 @@ -368,7 +368,7 @@
     3.4      impl->Deinitialize = ARTS_Deinitialize;
     3.5      impl->OnlyHasDefaultOutputDevice = 1;
     3.6  
     3.7 -    return 1;
     3.8 +    return 1;   /* this audio target is available. */
     3.9  }
    3.10  
    3.11  
     4.1 --- a/src/audio/baudio/SDL_beaudio.cc	Sun Jan 24 21:13:33 2010 +0000
     4.2 +++ b/src/audio/baudio/SDL_beaudio.cc	Tue Jan 26 06:01:33 2010 +0000
     4.3 @@ -204,7 +204,7 @@
     4.4      impl->ProvidesOwnCallbackThread = 1;
     4.5      impl->OnlyHasDefaultOutputDevice = 1;
     4.6  
     4.7 -    return 1;
     4.8 +    return 1;   /* this audio target is available. */
     4.9  }
    4.10  
    4.11  extern "C"
     5.1 --- a/src/audio/bsd/SDL_bsdaudio.c	Sun Jan 24 21:13:33 2010 +0000
     5.2 +++ b/src/audio/bsd/SDL_bsdaudio.c	Tue Jan 26 06:01:33 2010 +0000
     5.3 @@ -444,7 +444,8 @@
     5.4      impl->Deinitialize = BSDAUDIO_Deinitialize;
     5.5  
     5.6      build_device_lists();
     5.7 -    return (outputDeviceCount > 0) ? 2 : 1;
     5.8 +
     5.9 +    return 1;   /* this audio target is available. */
    5.10  }
    5.11  
    5.12  
     6.1 --- a/src/audio/disk/SDL_diskaudio.c	Sun Jan 24 21:13:33 2010 +0000
     6.2 +++ b/src/audio/disk/SDL_diskaudio.c	Tue Jan 26 06:01:33 2010 +0000
     6.3 @@ -158,7 +158,7 @@
     6.4      impl->GetDeviceBuf = DISKAUD_GetDeviceBuf;
     6.5      impl->CloseDevice = DISKAUD_CloseDevice;
     6.6  
     6.7 -    return 1;
     6.8 +    return 1;   /* this audio target is available. */
     6.9  }
    6.10  
    6.11  AudioBootStrap DISKAUD_bootstrap = {
     7.1 --- a/src/audio/dma/SDL_dmaaudio.c	Sun Jan 24 21:13:33 2010 +0000
     7.2 +++ b/src/audio/dma/SDL_dmaaudio.c	Tue Jan 26 06:01:33 2010 +0000
     7.3 @@ -524,7 +524,8 @@
     7.4      impl->Deinitialize = DMA_Deinitialize;
     7.5  
     7.6      build_device_lists();
     7.7 -    return (outputDeviceCount > 0) ? 2 : 1;
     7.8 +
     7.9 +    return 1;   /* this audio target is available. */
    7.10  }
    7.11  
    7.12  AudioBootStrap DMA_bootstrap = {
     8.1 --- a/src/audio/dmedia/SDL_irixaudio.c	Sun Jan 24 21:13:33 2010 +0000
     8.2 +++ b/src/audio/dmedia/SDL_irixaudio.c	Tue Jan 26 06:01:33 2010 +0000
     8.3 @@ -228,7 +228,7 @@
     8.4      impl->CloseDevice = DSP_CloseDevice;
     8.5      impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: not true, I think. */
     8.6  
     8.7 -    return 1;
     8.8 +    return 1;   /* this audio target is available. */
     8.9  }
    8.10  
    8.11  AudioBootStrap IRIXAUDIO_bootstrap = {
     9.1 --- a/src/audio/dsp/SDL_dspaudio.c	Sun Jan 24 21:13:33 2010 +0000
     9.2 +++ b/src/audio/dsp/SDL_dspaudio.c	Tue Jan 26 06:01:33 2010 +0000
     9.3 @@ -381,7 +381,8 @@
     9.4      impl->Deinitialize = DSP_Deinitialize;
     9.5  
     9.6      build_device_lists();
     9.7 -    return (outputDeviceCount > 0) ? 2 : 1;
     9.8 +
     9.9 +    return 1;   /* this audio target is available. */
    9.10  }
    9.11  
    9.12  
    10.1 --- a/src/audio/dummy/SDL_dummyaudio.c	Sun Jan 24 21:13:33 2010 +0000
    10.2 +++ b/src/audio/dummy/SDL_dummyaudio.c	Tue Jan 26 06:01:33 2010 +0000
    10.3 @@ -41,7 +41,7 @@
    10.4      /* Set the function pointers */
    10.5      impl->OpenDevice = DUMMYAUD_OpenDevice;
    10.6      impl->OnlyHasDefaultOutputDevice = 1;
    10.7 -    return 1;
    10.8 +    return 1;   /* this audio target is available. */
    10.9  }
   10.10  
   10.11  AudioBootStrap DUMMYAUD_bootstrap = {
    11.1 --- a/src/audio/esd/SDL_esdaudio.c	Sun Jan 24 21:13:33 2010 +0000
    11.2 +++ b/src/audio/esd/SDL_esdaudio.c	Tue Jan 26 06:01:33 2010 +0000
    11.3 @@ -341,7 +341,7 @@
    11.4      impl->Deinitialize = ESD_Deinitialize;
    11.5      impl->OnlyHasDefaultOutputDevice = 1;
    11.6  
    11.7 -    return 2;                   /* return 2 (definitely have a "device"). */
    11.8 +    return 1;   /* this audio target is available. */
    11.9  }
   11.10  
   11.11  
    12.1 --- a/src/audio/fusionsound/SDL_fsaudio.c	Sun Jan 24 21:13:33 2010 +0000
    12.2 +++ b/src/audio/fusionsound/SDL_fsaudio.c	Tue Jan 26 06:01:33 2010 +0000
    12.3 @@ -340,7 +340,7 @@
    12.4      impl->Deinitialize = SDL_FS_Deinitialize;
    12.5      impl->OnlyHasDefaultOutputDevice = 1;
    12.6  
    12.7 -    return 1;
    12.8 +    return 1;   /* this audio target is available. */
    12.9  }
   12.10  
   12.11  
    13.1 --- a/src/audio/iphoneos/SDL_coreaudio_iphone.c	Sun Jan 24 21:13:33 2010 +0000
    13.2 +++ b/src/audio/iphoneos/SDL_coreaudio_iphone.c	Tue Jan 26 06:01:33 2010 +0000
    13.3 @@ -329,7 +329,7 @@
    13.4      impl->OnlyHasDefaultOutputDevice = 1;
    13.5      impl->HasCaptureSupport = 0;        /* still needs to be written */
    13.6  
    13.7 -    return 2;                   /* defitely have an audio device. */
    13.8 +    return 1;   /* this audio target is available. */
    13.9  }
   13.10  
   13.11  AudioBootStrap COREAUDIOIPHONE_bootstrap = {
    14.1 --- a/src/audio/macosx/SDL_coreaudio.c	Sun Jan 24 21:13:33 2010 +0000
    14.2 +++ b/src/audio/macosx/SDL_coreaudio.c	Tue Jan 26 06:01:33 2010 +0000
    14.3 @@ -574,7 +574,7 @@
    14.4  
    14.5      build_device_lists();       /* do an initial check for devices... */
    14.6  
    14.7 -    return (outputDeviceCount > 0) ? 2 : 1;
    14.8 +    return 1;   /* this audio target is available. */
    14.9  }
   14.10  
   14.11  AudioBootStrap COREAUDIO_bootstrap = {
    15.1 --- a/src/audio/mme/SDL_mmeaudio.c	Sun Jan 24 21:13:33 2010 +0000
    15.2 +++ b/src/audio/mme/SDL_mmeaudio.c	Tue Jan 26 06:01:33 2010 +0000
    15.3 @@ -249,7 +249,7 @@
    15.4      impl->CloseDevice = MME_CloseDevice;
    15.5      impl->OnlyHasDefaultOutputDevice = 1;
    15.6  
    15.7 -    return 1;
    15.8 +    return 1;   /* this audio target is available. */
    15.9  }
   15.10  
   15.11  /* !!! FIXME: Windows "windib" driver is called waveout, too */
    16.1 --- a/src/audio/nas/SDL_nasaudio.c	Sun Jan 24 21:13:33 2010 +0000
    16.2 +++ b/src/audio/nas/SDL_nasaudio.c	Tue Jan 26 06:01:33 2010 +0000
    16.3 @@ -398,7 +398,7 @@
    16.4      impl->Deinitialize = NAS_Deinitialize;
    16.5      impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: is this true? */
    16.6  
    16.7 -    return 2;                   /* 2 == definitely has an audio device. */
    16.8 +    return 1;   /* this audio target is available. */
    16.9  }
   16.10  
   16.11  AudioBootStrap NAS_bootstrap = {
    17.1 --- a/src/audio/nds/SDL_ndsaudio.c	Sun Jan 24 21:13:33 2010 +0000
    17.2 +++ b/src/audio/nds/SDL_ndsaudio.c	Tue Jan 26 06:01:33 2010 +0000
    17.3 @@ -120,7 +120,7 @@
    17.4      impl->OnlyHasDefaultOutputDevice = 1;
    17.5      impl->OnlyHasDefaultInputDevice = 1;
    17.6  
    17.7 -    return 2;                   /* 2 == definitely has an audio device. */
    17.8 +    return 1;   /* this audio target is available. */
    17.9  }
   17.10  
   17.11  AudioBootStrap NDSAUD_bootstrap = {
    18.1 --- a/src/audio/paudio/SDL_paudio.c	Sun Jan 24 21:13:33 2010 +0000
    18.2 +++ b/src/audio/paudio/SDL_paudio.c	Tue Jan 26 06:01:33 2010 +0000
    18.3 @@ -544,8 +544,7 @@
    18.4      impl->CloseDevice = DSP_CloseDevice;
    18.5      impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: add device enum! */
    18.6  
    18.7 -    /* !!! FIXME: device enum might make this 1. */
    18.8 -    return 2;                   /* 2 == definitely has an audio device. */
    18.9 +    return 1;   /* this audio target is available. */
   18.10  }
   18.11  
   18.12  AudioBootStrap PAUDIO_bootstrap = {
    19.1 --- a/src/audio/pulseaudio/SDL_pulseaudio.c	Sun Jan 24 21:13:33 2010 +0000
    19.2 +++ b/src/audio/pulseaudio/SDL_pulseaudio.c	Tue Jan 26 06:01:33 2010 +0000
    19.3 @@ -529,8 +529,7 @@
    19.4      impl->Deinitialize = PULSEAUDIO_Deinitialize;
    19.5      impl->OnlyHasDefaultOutputDevice = 1;
    19.6  
    19.7 -    /* !!! FIXME: should test if server is available here, return 2 if so. */
    19.8 -    return 1;
    19.9 +    return 1;   /* this audio target is available. */
   19.10  }
   19.11  
   19.12  
    20.1 --- a/src/audio/qsa/SDL_qsa_audio.c	Sun Jan 24 21:13:33 2010 +0000
    20.2 +++ b/src/audio/qsa/SDL_qsa_audio.c	Tue Jan 26 06:01:33 2010 +0000
    20.3 @@ -883,8 +883,7 @@
    20.4          return 1;
    20.5      }
    20.6  
    20.7 -    /* At this point we are definitely has an audio device */
    20.8 -    return 2;
    20.9 +    return 1;   /* this audio target is available. */
   20.10  }
   20.11  
   20.12  AudioBootStrap QSAAUDIO_bootstrap = {
    21.1 --- a/src/audio/windib/SDL_dibaudio.c	Sun Jan 24 21:13:33 2010 +0000
    21.2 +++ b/src/audio/windib/SDL_dibaudio.c	Tue Jan 26 06:01:33 2010 +0000
    21.3 @@ -327,8 +327,7 @@
    21.4      impl->CloseDevice = WINWAVEOUT_CloseDevice;
    21.5      impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: Is this true? */
    21.6  
    21.7 -    /* !!! FIXME: not right for device enum? */
    21.8 -    return 1;
    21.9 +    return 1;   /* this audio target is available. */
   21.10  }
   21.11  
   21.12  AudioBootStrap WINWAVEOUT_bootstrap = {
    22.1 --- a/src/audio/windx5/SDL_dx5audio.c	Sun Jan 24 21:13:33 2010 +0000
    22.2 +++ b/src/audio/windx5/SDL_dx5audio.c	Tue Jan 26 06:01:33 2010 +0000
    22.3 @@ -508,8 +508,7 @@
    22.4      impl->Deinitialize = DSOUND_Deinitialize;
    22.5      impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME */
    22.6  
    22.7 -    /* !!! FIXME: not right for device enum? */
    22.8 -    return 1;
    22.9 +    return 1;   /* this audio target is available. */
   22.10  }
   22.11  
   22.12  AudioBootStrap DSOUND_bootstrap = {