Removed distinction between "available" and "init" in audio backends, since SDL-ryan-multiple-audio-device
authorRyan C. Gordon <icculus@icculus.org>
Tue, 17 Oct 2006 09:09:21 +0000
branchSDL-ryan-multiple-audio-device
changeset 384666fb40445587
parent 3845 ee5dfa7f7993
child 4415 2bf2dee62ea7
Removed distinction between "available" and "init" in audio backends, since
both had to be checked for success as a pair at the higher level and several
of the Available methods were just always-succeed placeholders anyhow. Now
the availability check is done in the init code, and the higher level tries
all possible drivers until one manages to initialize successfully.
src/audio/SDL_audio.c
src/audio/SDL_sysaudio.h
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/dart/SDL_dart.c
src/audio/dc/SDL_dcaudio.c
src/audio/disk/SDL_diskaudio.c
src/audio/dma/SDL_dmaaudio.c
src/audio/dma/SDL_dmaaudio.h
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/macosx/SDL_coreaudio.c
src/audio/macrom/SDL_romaudio.c
src/audio/mint/SDL_mintaudio_dma8.c
src/audio/mint/SDL_mintaudio_gsxb.c
src/audio/mint/SDL_mintaudio_mcsn.c
src/audio/mint/SDL_mintaudio_stfa.c
src/audio/mint/SDL_mintaudio_xbios.c
src/audio/mme/SDL_mmeaudio.c
src/audio/nas/SDL_nasaudio.c
src/audio/nto/SDL_nto_audio.c
src/audio/paudio/SDL_paudio.c
src/audio/windib/SDL_dibaudio.c
src/audio/windx5/SDL_dx5audio.c
     1.1 --- a/src/audio/SDL_audio.c	Tue Oct 17 08:04:51 2006 +0000
     1.2 +++ b/src/audio/SDL_audio.c	Tue Oct 17 09:09:21 2006 +0000
     1.3 @@ -360,6 +360,7 @@
     1.4  {
     1.5      int i = 0;
     1.6      int initialized = 0;
     1.7 +    int tried_to_init = 0;
     1.8  
     1.9      if (SDL_WasInit(SDL_INIT_AUDIO)) {
    1.10          SDL_AudioQuit();  /* shutdown driver if already running. */
    1.11 @@ -373,36 +374,31 @@
    1.12          driver_name = SDL_getenv("SDL_AUDIODRIVER");
    1.13      }
    1.14  
    1.15 -    /* !!! FIXME: what's the point of separating available() and init()? */
    1.16 -    if (driver_name != NULL) {
    1.17 -        for (i = 0; bootstrap[i]; ++i) {
    1.18 -            if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
    1.19 -                if (bootstrap[i]->available()) {
    1.20 -                    SDL_memset(&current_audio, 0, sizeof (current_audio));
    1.21 -                    current_audio.name = bootstrap[i]->name;
    1.22 -                    current_audio.desc = bootstrap[i]->desc;
    1.23 -                    initialized = bootstrap[i]->init(&current_audio.impl);
    1.24 -                }
    1.25 -                break;
    1.26 -            }
    1.27 +    for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
    1.28 +        /* make sure we should even try this driver before doing so... */
    1.29 +        const AudioBootStrap *backend = bootstrap[i];
    1.30 +        if ( ((driver_name) && (SDL_strcasecmp(backend->name, driver_name))) ||
    1.31 +             ((!driver_name) && (backend->demand_only)) ) {
    1.32 +            continue;
    1.33          }
    1.34 -    } else {
    1.35 -        for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
    1.36 -            if ((!bootstrap[i]->demand_only) && (bootstrap[i]->available())) {
    1.37 -                SDL_memset(&current_audio, 0, sizeof (current_audio));
    1.38 -                current_audio.name = bootstrap[i]->name;
    1.39 -                current_audio.desc = bootstrap[i]->desc;
    1.40 -                initialized = bootstrap[i]->init(&current_audio.impl);
    1.41 -            }
    1.42 -        }
    1.43 +
    1.44 +        tried_to_init = 1;
    1.45 +        SDL_memset(&current_audio, 0, sizeof (current_audio));
    1.46 +        current_audio.name = backend->name;
    1.47 +        current_audio.desc = backend->desc;
    1.48 +        initialized = backend->init(&current_audio.impl);
    1.49      }
    1.50  
    1.51      if (!initialized) {
    1.52 -        if (driver_name) {
    1.53 -            SDL_SetError("%s not available", driver_name);
    1.54 -        } else {
    1.55 -            SDL_SetError("No available audio device");
    1.56 +        /* specific drivers will set the error message if they fail... */
    1.57 +        if (!tried_to_init) {
    1.58 +            if (driver_name) {
    1.59 +                SDL_SetError("%s not available", driver_name);
    1.60 +            } else {
    1.61 +                SDL_SetError("No available audio device");
    1.62 +            }
    1.63          }
    1.64 +
    1.65          SDL_memset(&current_audio, 0, sizeof (current_audio));
    1.66          return (-1);  /* No driver was available, so fail. */
    1.67      }
     2.1 --- a/src/audio/SDL_sysaudio.h	Tue Oct 17 08:04:51 2006 +0000
     2.2 +++ b/src/audio/SDL_sysaudio.h	Tue Oct 17 09:09:21 2006 +0000
     2.3 @@ -107,10 +107,10 @@
     2.4  {
     2.5      const char *name;
     2.6      const char *desc;
     2.7 -    int (*available) (void);
     2.8      int (*init) (SDL_AudioDriverImpl *impl);
     2.9      int demand_only:1;  /* 1==request explicitly, or it won't be available. */
    2.10  } AudioBootStrap;
    2.11  
    2.12  #endif /* _SDL_sysaudio_h */
    2.13 +
    2.14  /* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 17 08:04:51 2006 +0000
     3.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 17 09:09:21 2006 +0000
     3.3 @@ -151,12 +151,10 @@
     3.4  
     3.5  #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
     3.6  
     3.7 -static int library_load_count = 0;
     3.8 -
     3.9  static void
    3.10  UnloadALSALibrary(void)
    3.11  {
    3.12 -    if ((alsa_handle != NULL) && (--library_load_count == 0)) {
    3.13 +    if (alsa_handle != NULL) {
    3.14          dlclose(alsa_handle);
    3.15          alsa_handle = NULL;
    3.16      }
    3.17 @@ -166,10 +164,9 @@
    3.18  LoadALSALibrary(void)
    3.19  {
    3.20      int retval = 0;
    3.21 -    if (library_load_count++ == 0) {
    3.22 +    if (alsa_handle == NULL) {
    3.23          alsa_handle = dlopen(alsa_library, RTLD_NOW);
    3.24          if (alsa_handle == NULL) {
    3.25 -            library_load_count--;
    3.26              retval = -1;
    3.27              SDL_SetError("ALSA: dlopen('%s') failed: %s\n",
    3.28                            alsa_library, strerror(errno));
    3.29 @@ -217,20 +214,6 @@
    3.30  }
    3.31  
    3.32  
    3.33 -static int
    3.34 -ALSA_Available(void)
    3.35 -{
    3.36 -    int available = 0;
    3.37 -
    3.38 -    if (LoadALSALibrary() >= 0) {
    3.39 -        available = 1;
    3.40 -        UnloadALSALibrary();
    3.41 -    }
    3.42 -    return (available);
    3.43 -}
    3.44 -
    3.45 -
    3.46 -
    3.47  /* This function waits until it is possible to write a full sound buffer */
    3.48  static void
    3.49  ALSA_WaitDevice(_THIS)
    3.50 @@ -377,7 +360,6 @@
    3.51          }
    3.52          SDL_free(this->hidden);
    3.53          this->hidden = NULL;
    3.54 -        UnloadALSALibrary();
    3.55      }
    3.56  }
    3.57  
    3.58 @@ -401,11 +383,6 @@
    3.59      }
    3.60      SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    3.61  
    3.62 -    if (LoadALSALibrary() < 0) {
    3.63 -        ALSA_CloseDevice(this);
    3.64 -        return 0;
    3.65 -    }
    3.66 -
    3.67      /* Open the audio device */
    3.68      /* Name of device should depend on # channels in spec */
    3.69      status = ALSA_snd_pcm_open(&pcm_handle,
    3.70 @@ -599,15 +576,26 @@
    3.71      return 1;
    3.72  }
    3.73  
    3.74 +static void
    3.75 +ALSA_Deinitialize(void)
    3.76 +{
    3.77 +    UnloadALSALibrary();
    3.78 +}
    3.79 +
    3.80  static int
    3.81  ALSA_Init(SDL_AudioDriverImpl *impl)
    3.82  {
    3.83 +    if (LoadALSALibrary() < 0) {
    3.84 +        return 0;
    3.85 +    }
    3.86 +
    3.87      /* Set the function pointers */
    3.88      impl->OpenDevice = ALSA_OpenDevice;
    3.89      impl->WaitDevice = ALSA_WaitDevice;
    3.90      impl->GetDeviceBuf = ALSA_GetDeviceBuf;
    3.91      impl->PlayDevice = ALSA_PlayDevice;
    3.92      impl->CloseDevice = ALSA_CloseDevice;
    3.93 +    impl->Deinitialize = ALSA_Deinitialize;
    3.94      impl->OnlyHasDefaultOutputDevice = 1;  /* !!! FIXME: Add device enum! */
    3.95  
    3.96      return 1;
    3.97 @@ -615,8 +603,7 @@
    3.98  
    3.99  
   3.100  AudioBootStrap ALSA_bootstrap = {
   3.101 -    DRIVER_NAME, "ALSA 0.9 PCM audio",
   3.102 -    ALSA_Available, ALSA_Init, 0
   3.103 +    DRIVER_NAME, "ALSA 0.9 PCM audio", ALSA_Init, 0
   3.104  };
   3.105  
   3.106  /* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/audio/arts/SDL_artsaudio.c	Tue Oct 17 08:04:51 2006 +0000
     4.2 +++ b/src/audio/arts/SDL_artsaudio.c	Tue Oct 17 09:09:21 2006 +0000
     4.3 @@ -126,32 +126,6 @@
     4.4  
     4.5  #endif /* SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
     4.6  
     4.7 -/* Audio driver bootstrap functions */
     4.8 -
     4.9 -static int
    4.10 -ARTS_Available(void)
    4.11 -{
    4.12 -    int available = 0;
    4.13 -
    4.14 -    if (LoadARTSLibrary() == 0) {
    4.15 -        if (SDL_NAME(arts_init) () == 0) {
    4.16 -#define ARTS_CRASH_HACK         /* Play a stream so aRts doesn't crash */
    4.17 -#ifdef ARTS_CRASH_HACK
    4.18 -            arts_stream_t stream;
    4.19 -            stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL");
    4.20 -            SDL_NAME(arts_write) (stream, "", 0);
    4.21 -            SDL_NAME(arts_close_stream) (stream);
    4.22 -#endif
    4.23 -            available = 1;
    4.24 -            SDL_NAME(arts_free) ();
    4.25 -        }
    4.26 -        UnloadARTSLibrary();
    4.27 -    }
    4.28 -
    4.29 -    return available;
    4.30 -}
    4.31 -
    4.32 -
    4.33  /* This function waits until it is possible to write a full sound buffer */
    4.34  static void
    4.35  ARTS_WaitDevice(_THIS)
    4.36 @@ -232,7 +206,6 @@
    4.37          SDL_free(this->hidden);
    4.38          this->hidden = NULL;
    4.39      }
    4.40 -    UnloadARTSLibrary();
    4.41  }
    4.42  
    4.43  
    4.44 @@ -252,12 +225,6 @@
    4.45      }
    4.46      SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    4.47  
    4.48 -    if (LoadARTSLibrary() < 0) {
    4.49 -        ARTS_CloseDevice(this);
    4.50 -        SDL_SetError("ARTS: failed to load library: %s", SDL_GetError());
    4.51 -        return 0;
    4.52 -    }
    4.53 -
    4.54      /* Try for a closest match on audio format */
    4.55      for (test_format = SDL_FirstAudioFormat(this->spec.format);
    4.56           !format && test_format;) {
    4.57 @@ -341,9 +308,33 @@
    4.58  }
    4.59  
    4.60  
    4.61 +static void
    4.62 +ARTS_Deinitialize(void)
    4.63 +{
    4.64 +    UnloadARTSLibrary();
    4.65 +}
    4.66 +
    4.67 +
    4.68  static int
    4.69  ARTS_Init(SDL_AudioDriverImpl *impl)
    4.70  {
    4.71 +    if (LoadARTSLibrary() < 0) {
    4.72 +        return 0;
    4.73 +    } else {
    4.74 +        if (SDL_NAME(arts_init) () != 0) {
    4.75 +            UnloadARTSLibrary();
    4.76 +            SDL_SetError("ARTS: arts_init failed (no audio server?)");
    4.77 +            return 0;
    4.78 +        }
    4.79 +
    4.80 +        /* Play a stream so aRts doesn't crash */
    4.81 +        arts_stream_t stream;
    4.82 +        stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL");
    4.83 +        SDL_NAME(arts_write) (stream, "", 0);
    4.84 +        SDL_NAME(arts_close_stream) (stream);
    4.85 +        SDL_NAME(arts_free) ();
    4.86 +    }
    4.87 +
    4.88      /* Set the function pointers */
    4.89      impl->OpenDevice = ARTS_OpenDevice;
    4.90      impl->PlayDevice = ARTS_PlayDevice;
    4.91 @@ -351,6 +342,7 @@
    4.92      impl->GetDeviceBuf = ARTS_GetDeviceBuf;
    4.93      impl->CloseDevice = ARTS_CloseDevice;
    4.94      impl->WaitDone = ARTS_WaitDone;
    4.95 +    impl->Deinitialize = ARTS_Deinitialize;
    4.96      impl->OnlyHasDefaultOutputDevice = 1;
    4.97  
    4.98      return 1;
    4.99 @@ -358,8 +350,7 @@
   4.100  
   4.101  
   4.102  AudioBootStrap ARTS_bootstrap = {
   4.103 -    ARTS_DRIVER_NAME, "Analog RealTime Synthesizer",
   4.104 -    ARTS_Available, ARTS_Init, 0
   4.105 +    ARTS_DRIVER_NAME, "Analog RealTime Synthesizer", ARTS_Init, 0
   4.106  };
   4.107  
   4.108  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/audio/baudio/SDL_beaudio.cc	Tue Oct 17 08:04:51 2006 +0000
     5.2 +++ b/src/audio/baudio/SDL_beaudio.cc	Tue Oct 17 09:09:21 2006 +0000
     5.3 @@ -39,12 +39,6 @@
     5.4  }
     5.5  
     5.6  
     5.7 -static int BEOSAUDIO_Available(void)
     5.8 -{
     5.9 -    return 1;  /* Always available on BeOS. */
    5.10 -}
    5.11 -
    5.12 -
    5.13  /* !!! FIXME: have the callback call the higher level to avoid code dupe. */
    5.14  /* The BeOS callback for handling the audio buffer */
    5.15  static void
    5.16 @@ -215,8 +209,7 @@
    5.17  
    5.18  extern "C" { extern AudioBootStrap BEOSAUDIO_bootstrap; }
    5.19  AudioBootStrap BEOSAUDIO_bootstrap = {
    5.20 -    "baudio", "BeOS BSoundPlayer",
    5.21 -    BEOSAUDIO_Available, BEOSAUDIO_Init, 0
    5.22 +    "baudio", "BeOS BSoundPlayer", BEOSAUDIO_Init, 0
    5.23  };
    5.24  
    5.25  /* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/audio/bsd/SDL_bsdaudio.c	Tue Oct 17 08:04:51 2006 +0000
     6.2 +++ b/src/audio/bsd/SDL_bsdaudio.c	Tue Oct 17 09:09:21 2006 +0000
     6.3 @@ -104,17 +104,6 @@
     6.4  }
     6.5  
     6.6  
     6.7 -static int
     6.8 -BSDAUDIO_Available(void)
     6.9 -{
    6.10 -    int available = 0;
    6.11 -    build_device_lists();
    6.12 -    available = ((outputDeviceCount > 0) || (inputDeviceCount > 0));
    6.13 -    free_device_lists();
    6.14 -    return available;
    6.15 -}
    6.16 -
    6.17 -
    6.18  static void
    6.19  BSDAUDIO_Deinitialize(void)
    6.20  {
    6.21 @@ -443,14 +432,14 @@
    6.22  BSDAUDIO_Init(SDL_AudioDriverImpl *impl)
    6.23  {
    6.24      /* Set the function pointers */
    6.25 -    impl->DetectDevices = DSP_DetectDevices;
    6.26 -    impl->GetDeviceName = DSP_GetDeviceName;
    6.27 -    impl->OpenDevice = DSP_OpenDevice;
    6.28 -    impl->PlayDevice = DSP_PlayDevice;
    6.29 -    impl->WaitDevice = DSP_WaitDevice;
    6.30 -    impl->GetDeviceBuf = DSP_GetDeviceBuf;
    6.31 -    impl->CloseDevice = DSP_CloseDevice;
    6.32 -    impl->Deinitialize = DSP_Deinitialize;
    6.33 +    impl->DetectDevices = BSDAUDIO_DetectDevices;
    6.34 +    impl->GetDeviceName = BSDAUDIO_GetDeviceName;
    6.35 +    impl->OpenDevice = BSDAUDIO_OpenDevice;
    6.36 +    impl->PlayDevice = BSDAUDIO_PlayDevice;
    6.37 +    impl->WaitDevice = BSDAUDIO_WaitDevice;
    6.38 +    impl->GetDeviceBuf = BSDAUDIO_GetDeviceBuf;
    6.39 +    impl->CloseDevice = BSDAUDIO_CloseDevice;
    6.40 +    impl->Deinitialize = BSDAUDIO_Deinitialize;
    6.41  
    6.42      build_device_lists();
    6.43      return 1;
    6.44 @@ -458,8 +447,7 @@
    6.45  
    6.46  
    6.47  AudioBootStrap BSD_AUDIO_bootstrap = {
    6.48 -    BSD_AUDIO_DRIVER_NAME, BSD_AUDIO_DRIVER_DESC,
    6.49 -    BSDAUDIO_Available, BSDAUDIO_Init, 0
    6.50 +    BSD_AUDIO_DRIVER_NAME, BSD_AUDIO_DRIVER_DESC, BSDAUDIO_Init, 0
    6.51  };
    6.52  
    6.53  /* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/audio/dart/SDL_dart.c	Tue Oct 17 08:04:51 2006 +0000
     7.2 +++ b/src/audio/dart/SDL_dart.c	Tue Oct 17 09:09:21 2006 +0000
     7.3 @@ -427,11 +427,6 @@
     7.4      }
     7.5  }
     7.6  
     7.7 -static int
     7.8 -DART_Available(void)
     7.9 -{
    7.10 -    return 1;  /* Always available on OS/2 Warp */
    7.11 -}
    7.12  
    7.13  static int
    7.14  DART_Init(SDL_AudioDriverImpl *impl)
    7.15 @@ -451,8 +446,7 @@
    7.16  
    7.17  
    7.18  AudioBootStrap DART_bootstrap = {
    7.19 -    "dart", "OS/2 Direct Audio RouTines (DART)",
    7.20 -    DART_Available, DART_Init, 0
    7.21 +    "dart", "OS/2 Direct Audio RouTines (DART)", DART_Init, 0
    7.22  };
    7.23  
    7.24  /* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/audio/dc/SDL_dcaudio.c	Tue Oct 17 08:04:51 2006 +0000
     8.2 +++ b/src/audio/dc/SDL_dcaudio.c	Tue Oct 17 09:09:21 2006 +0000
     8.3 @@ -225,12 +225,6 @@
     8.4  }
     8.5  
     8.6  static int
     8.7 -DCAUD_Available(void)
     8.8 -{
     8.9 -    return 1;  /* Dreamcast hardware is always available.  :) */
    8.10 -}
    8.11 -
    8.12 -static int
    8.13  DCAUD_Init(SDL_AudioDriverImpl *impl)
    8.14  {
    8.15      /* Set the function pointers */
    8.16 @@ -245,8 +239,7 @@
    8.17  }
    8.18  
    8.19  AudioBootStrap DCAUD_bootstrap = {
    8.20 -    "dcaudio", "Dreamcast AICA audio",
    8.21 -    DCAUD_Available, DCAUD_Init, 0
    8.22 +    "dcaudio", "Dreamcast AICA audio", DCAUD_Init, 0
    8.23  };
    8.24  
    8.25  /* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/src/audio/disk/SDL_diskaudio.c	Tue Oct 17 08:04:51 2006 +0000
     9.2 +++ b/src/audio/disk/SDL_diskaudio.c	Tue Oct 17 09:09:21 2006 +0000
     9.3 @@ -57,13 +57,6 @@
     9.4      return devname;
     9.5  }
     9.6  
     9.7 -/* Audio driver bootstrap functions */
     9.8 -static int
     9.9 -DISKAUD_Available(void)
    9.10 -{
    9.11 -    return 1;  /* always available. */
    9.12 -}
    9.13 -
    9.14  /* This function waits until it is possible to write a full sound buffer */
    9.15  static void
    9.16  DISKAUD_WaitDevice(_THIS)
    9.17 @@ -158,9 +151,6 @@
    9.18  static int
    9.19  DISKAUD_Init(SDL_AudioDriverImpl *impl)
    9.20  {
    9.21 -    /* Initialize all variables that we clean on shutdown */
    9.22 -    SDL_memset(impl, '\0', sizeof (SDL_AudioDriverImpl));
    9.23 -
    9.24      /* Set the function pointers */
    9.25      impl->OpenDevice = DISKAUD_OpenDevice;
    9.26      impl->WaitDevice = DISKAUD_WaitDevice;
    9.27 @@ -172,8 +162,7 @@
    9.28  }
    9.29  
    9.30  AudioBootStrap DISKAUD_bootstrap = {
    9.31 -    DISKAUD_DRIVER_NAME, "direct-to-disk audio",
    9.32 -    DISKAUD_Available, DISKAUD_Init, 1
    9.33 +    DISKAUD_DRIVER_NAME, "direct-to-disk audio", DISKAUD_Init, 1
    9.34  };
    9.35  
    9.36  /* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/audio/dma/SDL_dmaaudio.c	Tue Oct 17 08:04:51 2006 +0000
    10.2 +++ b/src/audio/dma/SDL_dmaaudio.c	Tue Oct 17 09:09:21 2006 +0000
    10.3 @@ -116,15 +116,6 @@
    10.4      free_device_list(&inputDevices, &inputDeviceCount);
    10.5  }
    10.6  
    10.7 -static int
    10.8 -DMA_Available(void)
    10.9 -{
   10.10 -    int available = 0;
   10.11 -    build_device_lists();
   10.12 -    available = ((outputDeviceCount > 0) || (inputDeviceCount > 0));
   10.13 -    free_device_lists();
   10.14 -    return available;
   10.15 -}
   10.16  
   10.17  static void DMA_Deinitialize(void)
   10.18  {
   10.19 @@ -537,8 +528,7 @@
   10.20  }
   10.21  
   10.22  AudioBootStrap DMA_bootstrap = {
   10.23 -    DMA_DRIVER_NAME, "OSS /dev/dsp DMA audio",
   10.24 -    DMA_Available, DMA_Init, 0
   10.25 +    DMA_DRIVER_NAME, "OSS /dev/dsp DMA audio", DMA_Init, 0
   10.26  };
   10.27  
   10.28  /* vi: set ts=4 sw=4 expandtab: */
    11.1 --- a/src/audio/dma/SDL_dmaaudio.h	Tue Oct 17 08:04:51 2006 +0000
    11.2 +++ b/src/audio/dma/SDL_dmaaudio.h	Tue Oct 17 09:09:21 2006 +0000
    11.3 @@ -21,8 +21,8 @@
    11.4  */
    11.5  #include "SDL_config.h"
    11.6  
    11.7 -#ifndef _SDL_dspaudio_h
    11.8 -#define _SDL_dspaudio_h
    11.9 +#ifndef _SDL_dmaaudio_h
   11.10 +#define _SDL_dmaaudio_h
   11.11  
   11.12  #include "../SDL_sysaudio.h"
   11.13  
   11.14 @@ -49,6 +49,7 @@
   11.15  #define FUDGE_TICKS	10      /* The scheduler overhead ticks per frame */
   11.16  
   11.17  /* Old variable names */
   11.18 +/* !!! FIXME: remove these. */
   11.19  #define audio_fd		(this->hidden->audio_fd)
   11.20  #define parent			(this->hidden->parent)
   11.21  #define dma_buf			(this->hidden->dma_buf)
   11.22 @@ -57,5 +58,6 @@
   11.23  #define frame_ticks		(this->hidden->frame_ticks)
   11.24  #define next_frame		(this->hidden->next_frame)
   11.25  
   11.26 -#endif /* _SDL_dspaudio_h */
   11.27 +#endif /* _SDL_dmaaudio_h */
   11.28 +
   11.29  /* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/audio/dmedia/SDL_irixaudio.c	Tue Oct 17 08:04:51 2006 +0000
    12.2 +++ b/src/audio/dmedia/SDL_irixaudio.c	Tue Oct 17 09:09:21 2006 +0000
    12.3 @@ -45,12 +45,6 @@
    12.4  #define alSetWidth(x,y) ALsetwidth(x,y)
    12.5  #endif
    12.6  
    12.7 -static int
    12.8 -IRIXAUDIO_Available(void)
    12.9 -{
   12.10 -    return 1;
   12.11 -}
   12.12 -
   12.13  void static
   12.14  IRIXAUDIO_WaitDevice(_THIS)
   12.15  {
   12.16 @@ -236,8 +230,7 @@
   12.17  }
   12.18  
   12.19  AudioBootStrap IRIXAUDIO_bootstrap = {
   12.20 -    "AL", "IRIX DMedia audio",
   12.21 -    IRIXAUDIO_Available, IRIXAUDIO_Init, 0
   12.22 +    "AL", "IRIX DMedia audio", IRIXAUDIO_Init, 0
   12.23  };
   12.24  
   12.25  /* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/audio/dsp/SDL_dspaudio.c	Tue Oct 17 08:04:51 2006 +0000
    13.2 +++ b/src/audio/dsp/SDL_dspaudio.c	Tue Oct 17 09:09:21 2006 +0000
    13.3 @@ -93,17 +93,6 @@
    13.4  }
    13.5  
    13.6  
    13.7 -static int
    13.8 -DSP_Available(void)
    13.9 -{
   13.10 -    int available = 0;
   13.11 -    build_device_lists();
   13.12 -    available = ((outputDeviceCount > 0) || (inputDeviceCount > 0));
   13.13 -    free_device_lists();
   13.14 -    return available;
   13.15 -}
   13.16 -
   13.17 -
   13.18  static void
   13.19  DSP_Deinitialize(void)
   13.20  {
   13.21 @@ -388,8 +377,7 @@
   13.22  
   13.23  
   13.24  AudioBootStrap DSP_bootstrap = {
   13.25 -    DSP_DRIVER_NAME, "OSS /dev/dsp standard audio",
   13.26 -    DSP_Available, DSP_Init, 0
   13.27 +    DSP_DRIVER_NAME, "OSS /dev/dsp standard audio", DSP_Init, 0
   13.28  };
   13.29  
   13.30  /* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/audio/dummy/SDL_dummyaudio.c	Tue Oct 17 08:04:51 2006 +0000
    14.2 +++ b/src/audio/dummy/SDL_dummyaudio.c	Tue Oct 17 09:09:21 2006 +0000
    14.3 @@ -25,42 +25,27 @@
    14.4  
    14.5  /* Output audio to nowhere... */
    14.6  
    14.7 -#include "SDL_rwops.h"
    14.8 -#include "SDL_timer.h"
    14.9  #include "SDL_audio.h"
   14.10 -#include "../SDL_audiomem.h"
   14.11  #include "../SDL_audio_c.h"
   14.12  #include "SDL_dummyaudio.h"
   14.13  
   14.14 -/* The tag name used by DUMMY audio */
   14.15 -#define DUMMYAUD_DRIVER_NAME         "dummy"
   14.16 -
   14.17 -static int
   14.18 -DUMMYAUD_Available(void)
   14.19 -{
   14.20 -    return 1;  /* always available. */
   14.21 -}
   14.22 -
   14.23  static int
   14.24  DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture)
   14.25  {
   14.26      return 1;   /* always succeeds. */
   14.27  }
   14.28  
   14.29 -
   14.30  static int
   14.31  DUMMYAUD_Init(SDL_AudioDriverImpl *impl)
   14.32  {
   14.33      /* Set the function pointers */
   14.34      impl->OpenDevice = DUMMYAUD_OpenDevice;
   14.35      impl->OnlyHasDefaultOutputDevice = 1;
   14.36 -
   14.37      return 1;
   14.38  }
   14.39  
   14.40  AudioBootStrap DUMMYAUD_bootstrap = {
   14.41 -    DUMMYAUD_DRIVER_NAME, "SDL dummy audio driver",
   14.42 -    DUMMYAUD_Available, DUMMYAUD_Init, 1
   14.43 +    "dummy", "SDL dummy audio driver", DUMMYAUD_Init, 1
   14.44  };
   14.45  
   14.46  /* vi: set ts=4 sw=4 expandtab: */
    15.1 --- a/src/audio/esd/SDL_esdaudio.c	Tue Oct 17 08:04:51 2006 +0000
    15.2 +++ b/src/audio/esd/SDL_esdaudio.c	Tue Oct 17 09:09:21 2006 +0000
    15.3 @@ -115,25 +115,6 @@
    15.4  
    15.5  #endif /* SDL_AUDIO_DRIVER_ESD_DYNAMIC */
    15.6  
    15.7 -static int
    15.8 -ESD_Available(void)
    15.9 -{
   15.10 -    int available = 0;
   15.11 -    if (LoadESDLibrary() == 0) {
   15.12 -        int connection;
   15.13 -        if (SDL_getenv("ESD_NO_SPAWN") == NULL) {
   15.14 -            SDL_putenv("ESD_NO_SPAWN=1"); /* Don't start ESD if it's not running */
   15.15 -        }
   15.16 -        connection = SDL_NAME(esd_open_sound) (NULL);
   15.17 -        if (connection >= 0) {
   15.18 -            available = 1;
   15.19 -            SDL_NAME(esd_close) (connection);
   15.20 -        }
   15.21 -        UnloadESDLibrary();
   15.22 -    }
   15.23 -    return available;
   15.24 -}
   15.25 -
   15.26  
   15.27  /* This function waits until it is possible to write a full sound buffer */
   15.28  static void
   15.29 @@ -210,7 +191,6 @@
   15.30          SDL_free(this->hidden);
   15.31          this->hidden = NULL;
   15.32      }
   15.33 -    UnloadESDLibrary();
   15.34  }
   15.35  
   15.36  /* Try to get the name of the program */
   15.37 @@ -257,12 +237,6 @@
   15.38      SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   15.39      this->hidden->audio_fd = -1;
   15.40  
   15.41 -    if (LoadESDLibrary() < 0) {
   15.42 -        ESD_CloseDevice(this);
   15.43 -        SDL_SetError("ESD: failed to load library: %s", SDL_GetError());
   15.44 -        return 0;
   15.45 -    }
   15.46 -
   15.47      /* Convert audio spec to the ESD audio format */
   15.48      /* Try for a closest match on audio format */
   15.49      for (test_format = SDL_FirstAudioFormat(this->spec.format);
   15.50 @@ -331,16 +305,41 @@
   15.51      return 1;
   15.52  }
   15.53  
   15.54 +static void
   15.55 +ESD_Deinitialize(void)
   15.56 +{
   15.57 +    UnloadESDLibrary();
   15.58 +}
   15.59  
   15.60  static int
   15.61  ESD_Init(SDL_AudioDriverImpl *impl)
   15.62  {
   15.63 +    if (LoadESDLibrary() < 0) {
   15.64 +        return 0;
   15.65 +    } else {
   15.66 +        int connection = 0;
   15.67 +
   15.68 +        /* Don't start ESD if it's not running */
   15.69 +        if (SDL_getenv("ESD_NO_SPAWN") == NULL) {
   15.70 +            SDL_putenv("ESD_NO_SPAWN=1");
   15.71 +        }
   15.72 +
   15.73 +        connection = SDL_NAME(esd_open_sound) (NULL);
   15.74 +        if (connection < 0) {
   15.75 +            UnloadESDLibrary();
   15.76 +            SDL_SetError("ESD: esd_open_sound failed (no audio server?)");
   15.77 +            return 0;
   15.78 +        }
   15.79 +        SDL_NAME(esd_close) (connection);
   15.80 +    }
   15.81 +
   15.82      /* Set the function pointers */
   15.83      impl->OpenDevice = ESD_OpenDevice;
   15.84      impl->PlayDevice = ESD_PlayDevice;
   15.85      impl->WaitDevice = ESD_WaitDevice;
   15.86      impl->GetDeviceBuf = ESD_GetDeviceBuf;
   15.87      impl->CloseDevice = ESD_CloseDevice;
   15.88 +    impl->Deinitialize = ESD_Deinitialize;
   15.89      impl->OnlyHasDefaultOutputDevice = 1;
   15.90  
   15.91      return 1;
   15.92 @@ -348,8 +347,7 @@
   15.93  
   15.94  
   15.95  AudioBootStrap ESD_bootstrap = {
   15.96 -    ESD_DRIVER_NAME, "Enlightened Sound Daemon",
   15.97 -    ESD_Available, ESD_Init, 0
   15.98 +    ESD_DRIVER_NAME, "Enlightened Sound Daemon", ESD_Init, 0
   15.99  };
  15.100  
  15.101  /* vi: set ts=4 sw=4 expandtab: */
    16.1 --- a/src/audio/macosx/SDL_coreaudio.c	Tue Oct 17 08:04:51 2006 +0000
    16.2 +++ b/src/audio/macosx/SDL_coreaudio.c	Tue Oct 17 09:09:21 2006 +0000
    16.3 @@ -201,11 +201,6 @@
    16.4      return 0;
    16.5  }
    16.6  
    16.7 -static int
    16.8 -COREAUDIO_Available(void)
    16.9 -{
   16.10 -    return 1;  /* always available on Mac OS X. */
   16.11 -}
   16.12  
   16.13  static int
   16.14  COREAUDIO_DetectDevices(int iscapture)
   16.15 @@ -582,8 +577,7 @@
   16.16  }
   16.17  
   16.18  AudioBootStrap COREAUDIO_bootstrap = {
   16.19 -    "coreaudio", "Mac OS X CoreAudio",
   16.20 -    COREAUDIO_Available, COREAUDIO_Init, 0
   16.21 +    "coreaudio", "Mac OS X CoreAudio", COREAUDIO_Init, 0
   16.22  };
   16.23  
   16.24  /* vi: set ts=4 sw=4 expandtab: */
    17.1 --- a/src/audio/macrom/SDL_romaudio.c	Tue Oct 17 08:04:51 2006 +0000
    17.2 +++ b/src/audio/macrom/SDL_romaudio.c	Tue Oct 17 09:09:21 2006 +0000
    17.3 @@ -50,13 +50,6 @@
    17.4  #include "../SDL_sysaudio.h"
    17.5  #include "SDL_romaudio.h"
    17.6  
    17.7 -static int
    17.8 -SNDMGR_Available(void)
    17.9 -{
   17.10 -    return (1);
   17.11 -}
   17.12 -
   17.13 -
   17.14  #pragma options align=power
   17.15  
   17.16  static volatile SInt32 audio_is_locked = 0;
   17.17 @@ -320,8 +313,7 @@
   17.18  }
   17.19  
   17.20  AudioBootStrap SNDMGR_bootstrap = {
   17.21 -    "sndmgr", SDL_MACOS_NAME " SoundManager",
   17.22 -    SNDMGR_Available, SNDMGR_Init, 0
   17.23 +    "sndmgr", SDL_MACOS_NAME " SoundManager", SNDMGR_Init, 0
   17.24  };
   17.25  
   17.26  /* vi: set ts=4 sw=4 expandtab: */
    18.1 --- a/src/audio/mint/SDL_mintaudio_dma8.c	Tue Oct 17 08:04:51 2006 +0000
    18.2 +++ b/src/audio/mint/SDL_mintaudio_dma8.c	Tue Oct 17 09:09:21 2006 +0000
    18.3 @@ -61,40 +61,6 @@
    18.4  
    18.5  static unsigned long cookie_snd, cookie_mch;
    18.6  
    18.7 -
    18.8 -static int
    18.9 -MINTDMA8_Available(void)
   18.10 -{
   18.11 -    /* Cookie _MCH present ? if not, assume ST machine */
   18.12 -    if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
   18.13 -        cookie_mch = MCH_ST;
   18.14 -    }
   18.15 -
   18.16 -    /* Cookie _SND present ? if not, assume ST machine */
   18.17 -    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   18.18 -        cookie_snd = SND_PSG;
   18.19 -    }
   18.20 -
   18.21 -    /* Check if we have 8 bits audio */
   18.22 -    if ((cookie_snd & SND_8BIT) == 0) {
   18.23 -        DEBUG_PRINT((DEBUG_NAME "no 8 bits sound\n"));
   18.24 -        return (0);
   18.25 -    }
   18.26 -
   18.27 -    /* Check if audio is lockable */
   18.28 -    if (cookie_snd & SND_16BIT) {
   18.29 -        if (Locksnd() != 1) {
   18.30 -            DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n"));
   18.31 -            return (0);
   18.32 -        }
   18.33 -
   18.34 -        Unlocksnd();
   18.35 -    }
   18.36 -
   18.37 -    DEBUG_PRINT((DEBUG_NAME "8 bits audio available!\n"));
   18.38 -    return (1);
   18.39 -}
   18.40 -
   18.41  static void
   18.42  MINTDMA8_LockDevice(_THIS)
   18.43  {
   18.44 @@ -330,6 +296,34 @@
   18.45  static int
   18.46  MINTDMA8_Init(SDL_AudioDriverImpl *impl)
   18.47  {
   18.48 +    /* Cookie _MCH present ? if not, assume ST machine */
   18.49 +    if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
   18.50 +        cookie_mch = MCH_ST;
   18.51 +    }
   18.52 +
   18.53 +    /* Cookie _SND present ? if not, assume ST machine */
   18.54 +    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   18.55 +        cookie_snd = SND_PSG;
   18.56 +    }
   18.57 +
   18.58 +    /* Check if we have 8 bits audio */
   18.59 +    if ((cookie_snd & SND_8BIT) == 0) {
   18.60 +        SDL_SetError(DEBUG_NAME "no 8 bits sound");
   18.61 +        return 0;
   18.62 +    }
   18.63 +
   18.64 +    /* Check if audio is lockable */
   18.65 +    if (cookie_snd & SND_16BIT) {
   18.66 +        if (Locksnd() != 1) {
   18.67 +            SDL_SetError(DEBUG_NAME "audio locked by other application");
   18.68 +            return 0;
   18.69 +        }
   18.70 +
   18.71 +        Unlocksnd();
   18.72 +    }
   18.73 +
   18.74 +    DEBUG_PRINT((DEBUG_NAME "8 bits audio available!\n"));
   18.75 +
   18.76      /* Set the function pointers */
   18.77      impl->OpenDevice = MINTDMA8_OpenDevice;
   18.78      impl->CloseDevice = MINTDMA8_CloseDevice;
   18.79 @@ -343,8 +337,7 @@
   18.80  }
   18.81  
   18.82  AudioBootStrap MINTAUDIO_DMA8_bootstrap = {
   18.83 -    MINT_AUDIO_DRIVER_NAME, "MiNT DMA 8 bits audio driver",
   18.84 -    MINTDMA8_Available, MINTDMA8_Init, 0
   18.85 +    MINT_AUDIO_DRIVER_NAME, "MiNT DMA 8 bits audio driver", MINTDMA8_Init, 0
   18.86  };
   18.87  
   18.88  /* vi: set ts=4 sw=4 expandtab: */
    19.1 --- a/src/audio/mint/SDL_mintaudio_gsxb.c	Tue Oct 17 08:04:51 2006 +0000
    19.2 +++ b/src/audio/mint/SDL_mintaudio_gsxb.c	Tue Oct 17 09:09:21 2006 +0000
    19.3 @@ -67,43 +67,6 @@
    19.4  static void MINTGSXB_GsxbInterrupt(void);
    19.5  static void MINTGSXB_GsxbNullInterrupt(void);
    19.6  
    19.7 -
    19.8 -static int
    19.9 -MINTGSXB_Available(void)
   19.10 -{
   19.11 -    /* Cookie _SND present ? if not, assume ST machine */
   19.12 -    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   19.13 -        cookie_snd = SND_PSG;
   19.14 -    }
   19.15 -
   19.16 -    /* Check if we have 16 bits audio */
   19.17 -    if ((cookie_snd & SND_16BIT) == 0) {
   19.18 -        DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n"));
   19.19 -        return (0);
   19.20 -    }
   19.21 -
   19.22 -    /* Cookie GSXB present ? */
   19.23 -    cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND);
   19.24 -
   19.25 -    /* Is it GSXB ? */
   19.26 -    if (((cookie_snd & SND_GSXB) == 0) || (cookie_gsxb == 0)) {
   19.27 -        DEBUG_PRINT((DEBUG_NAME "no GSXB audio\n"));
   19.28 -        return (0);
   19.29 -    }
   19.30 -
   19.31 -    /* Check if audio is lockable */
   19.32 -    if (Locksnd() != 1) {
   19.33 -        DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n"));
   19.34 -        return (0);
   19.35 -    }
   19.36 -
   19.37 -    Unlocksnd();
   19.38 -
   19.39 -    DEBUG_PRINT((DEBUG_NAME "GSXB audio available!\n"));
   19.40 -    return (1);
   19.41 -}
   19.42 -
   19.43 -
   19.44  static void
   19.45  MINTGSXB_LockDevice(_THIS)
   19.46  {
   19.47 @@ -427,6 +390,36 @@
   19.48  static int
   19.49  MINTGSXB_Init(SDL_AudioDriverImpl *impl)
   19.50  {
   19.51 +    /* Cookie _SND present ? if not, assume ST machine */
   19.52 +    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   19.53 +        cookie_snd = SND_PSG;
   19.54 +    }
   19.55 +
   19.56 +    /* Check if we have 16 bits audio */
   19.57 +    if ((cookie_snd & SND_16BIT) == 0) {
   19.58 +        SDL_SetError(DEBUG_NAME "no 16-bit sound");
   19.59 +        return 0;
   19.60 +    }
   19.61 +
   19.62 +    /* Cookie GSXB present ? */
   19.63 +    cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND);
   19.64 +
   19.65 +    /* Is it GSXB ? */
   19.66 +    if (((cookie_snd & SND_GSXB) == 0) || (cookie_gsxb == 0)) {
   19.67 +        SDL_SetError(DEBUG_NAME "no GSXB audio");
   19.68 +        return 0;
   19.69 +    }
   19.70 +
   19.71 +    /* Check if audio is lockable */
   19.72 +    if (Locksnd() != 1) {
   19.73 +        SDL_SetError(DEBUG_NAME "audio locked by other application");
   19.74 +        return 0;
   19.75 +    }
   19.76 +
   19.77 +    Unlocksnd();
   19.78 +
   19.79 +    DEBUG_PRINT((DEBUG_NAME "GSXB audio available!\n"));
   19.80 +
   19.81      /* Set the function pointers */
   19.82      impl->OpenDevice = MINTGSXB_OpenDevice;
   19.83      impl->CloseDevice = MINTGSXB_CloseDevice;
   19.84 @@ -440,8 +433,7 @@
   19.85  }
   19.86  
   19.87  AudioBootStrap MINTAUDIO_GSXB_bootstrap = {
   19.88 -    MINT_AUDIO_DRIVER_NAME, "MiNT GSXB audio driver",
   19.89 -    MINTGSXB_Available, MINTGSXB_Init, 0
   19.90 +    MINT_AUDIO_DRIVER_NAME, "MiNT GSXB audio driver", MINTGSXB_Init, 0
   19.91  };
   19.92  
   19.93  /* vi: set ts=4 sw=4 expandtab: */
    20.1 --- a/src/audio/mint/SDL_mintaudio_mcsn.c	Tue Oct 17 08:04:51 2006 +0000
    20.2 +++ b/src/audio/mint/SDL_mintaudio_mcsn.c	Tue Oct 17 09:09:21 2006 +0000
    20.3 @@ -65,58 +65,6 @@
    20.4  static unsigned long cookie_mch = 0;
    20.5  static cookie_mcsn_t *cookie_mcsn = NULL;
    20.6  
    20.7 -static int
    20.8 -MINTMCSN_Available(void)
    20.9 -{
   20.10 -    unsigned long dummy = 0;
   20.11 -
   20.12 -    SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
   20.13 -
   20.14 -    /* We can't use XBIOS in interrupt with Magic, don't know about thread */
   20.15 -    if (Getcookie(C_MagX, &dummy) == C_FOUND) {
   20.16 -        return (0);
   20.17 -    }
   20.18 -
   20.19 -    /* Cookie _MCH present ? if not, assume ST machine */
   20.20 -    if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
   20.21 -        cookie_mch = MCH_ST;
   20.22 -    }
   20.23 -
   20.24 -    /* Cookie _SND present ? if not, assume ST machine */
   20.25 -    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   20.26 -        cookie_snd = SND_PSG;
   20.27 -    }
   20.28 -
   20.29 -    /* Check if we have 16 bits audio */
   20.30 -    if ((cookie_snd & SND_16BIT) == 0) {
   20.31 -        DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n"));
   20.32 -        return (0);
   20.33 -    }
   20.34 -
   20.35 -    /* Cookie MCSN present ? */
   20.36 -    if (Getcookie(C_McSn, (long *) &cookie_mcsn) != C_FOUND) {
   20.37 -        DEBUG_PRINT((DEBUG_NAME "no MCSN audio\n"));
   20.38 -        return (0);
   20.39 -    }
   20.40 -
   20.41 -    /* Check if interrupt at end of replay */
   20.42 -    if (cookie_mcsn->pint == 0) {
   20.43 -        DEBUG_PRINT((DEBUG_NAME "no interrupt at end of replay\n"));
   20.44 -        return (0);
   20.45 -    }
   20.46 -
   20.47 -    /* Check if audio is lockable */
   20.48 -    if (Locksnd() != 1) {
   20.49 -        DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n"));
   20.50 -        return (0);
   20.51 -    }
   20.52 -
   20.53 -    Unlocksnd();
   20.54 -
   20.55 -    DEBUG_PRINT((DEBUG_NAME "MCSN audio available!\n"));
   20.56 -    return (1);
   20.57 -}
   20.58 -
   20.59  static void
   20.60  MINTMCSN_LockDevice(_THIS)
   20.61  {
   20.62 @@ -381,6 +329,53 @@
   20.63  static int
   20.64  MINTMCSN_Init(SDL_AudioDriverImpl *impl)
   20.65  {
   20.66 +    unsigned long dummy = 0;
   20.67 +
   20.68 +    SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
   20.69 +
   20.70 +    /* We can't use XBIOS in interrupt with Magic, don't know about thread */
   20.71 +    if (Getcookie(C_MagX, &dummy) == C_FOUND) {
   20.72 +        return 0;
   20.73 +    }
   20.74 +
   20.75 +    /* Cookie _MCH present ? if not, assume ST machine */
   20.76 +    if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
   20.77 +        cookie_mch = MCH_ST;
   20.78 +    }
   20.79 +
   20.80 +    /* Cookie _SND present ? if not, assume ST machine */
   20.81 +    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   20.82 +        cookie_snd = SND_PSG;
   20.83 +    }
   20.84 +
   20.85 +    /* Check if we have 16 bits audio */
   20.86 +    if ((cookie_snd & SND_16BIT) == 0) {
   20.87 +        SDL_SetError(DEBUG_NAME "no 16-bit sound");
   20.88 +        return 0;
   20.89 +    }
   20.90 +
   20.91 +    /* Cookie MCSN present ? */
   20.92 +    if (Getcookie(C_McSn, (long *) &cookie_mcsn) != C_FOUND) {
   20.93 +        SDL_SetError(DEBUG_NAME "no MCSN audio");
   20.94 +        return 0;
   20.95 +    }
   20.96 +
   20.97 +    /* Check if interrupt at end of replay */
   20.98 +    if (cookie_mcsn->pint == 0) {
   20.99 +        SDL_SetError(DEBUG_NAME "no interrupt at end of replay");
  20.100 +        return 0;
  20.101 +    }
  20.102 +
  20.103 +    /* Check if audio is lockable */
  20.104 +    if (Locksnd() != 1) {
  20.105 +        SDL_SetError(DEBUG_NAME "audio locked by other application");
  20.106 +        return 0;
  20.107 +    }
  20.108 +
  20.109 +    Unlocksnd();
  20.110 +
  20.111 +    DEBUG_PRINT((DEBUG_NAME "MCSN audio available!\n"));
  20.112 +
  20.113      /* Set the function pointers */
  20.114      impl->OpenDevice = MINTMCSN_OpenDevice;
  20.115      impl->CloseDevice = MINTMCSN_CloseDevice;
  20.116 @@ -394,8 +389,7 @@
  20.117  }
  20.118  
  20.119  AudioBootStrap MINTAUDIO_MCSN_bootstrap = {
  20.120 -    MINT_AUDIO_DRIVER_NAME, "MiNT MCSN audio driver",
  20.121 -    MINTMCSN_Available, MINTMCSN_Init, 0
  20.122 +    MINT_AUDIO_DRIVER_NAME, "MiNT MCSN audio driver", MINTMCSN_Init, 0
  20.123  };
  20.124  
  20.125  /* vi: set ts=4 sw=4 expandtab: */
    21.1 --- a/src/audio/mint/SDL_mintaudio_stfa.c	Tue Oct 17 08:04:51 2006 +0000
    21.2 +++ b/src/audio/mint/SDL_mintaudio_stfa.c	Tue Oct 17 09:09:21 2006 +0000
    21.3 @@ -70,31 +70,6 @@
    21.4      30720, 32336, 43885, 49152
    21.5  };
    21.6  
    21.7 -static int
    21.8 -MINTSTFA_Available(void)
    21.9 -{
   21.10 -    /* Cookie _MCH present ? if not, assume ST machine */
   21.11 -    if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
   21.12 -        cookie_mch = MCH_ST;
   21.13 -    }
   21.14 -
   21.15 -    /* Cookie _SND present ? if not, assume ST machine */
   21.16 -    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   21.17 -        cookie_snd = SND_PSG;
   21.18 -    }
   21.19 -
   21.20 -    /* Cookie STFA present ? */
   21.21 -    if (Getcookie(C_STFA, (long *) &cookie_stfa) != C_FOUND) {
   21.22 -        DEBUG_PRINT((DEBUG_NAME "no STFA audio\n"));
   21.23 -        return (0);
   21.24 -    }
   21.25 -
   21.26 -    SDL_MintAudio_stfa = cookie_stfa;
   21.27 -
   21.28 -    DEBUG_PRINT((DEBUG_NAME "STFA audio available!\n"));
   21.29 -    return (1);
   21.30 -}
   21.31 -
   21.32  static void
   21.33  MINTSTFA_LockDevice(_THIS)
   21.34  {
   21.35 @@ -288,6 +263,26 @@
   21.36  static int
   21.37  MINTSTFA_Init(SDL_AudioDriverImpl *impl)
   21.38  {
   21.39 +    /* Cookie _MCH present ? if not, assume ST machine */
   21.40 +    if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
   21.41 +        cookie_mch = MCH_ST;
   21.42 +    }
   21.43 +
   21.44 +    /* Cookie _SND present ? if not, assume ST machine */
   21.45 +    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   21.46 +        cookie_snd = SND_PSG;
   21.47 +    }
   21.48 +
   21.49 +    /* Cookie STFA present ? */
   21.50 +    if (Getcookie(C_STFA, (long *) &cookie_stfa) != C_FOUND) {
   21.51 +        SDL_SetError(DEBUG_NAME "no STFA audio");
   21.52 +        return (0);
   21.53 +    }
   21.54 +
   21.55 +    SDL_MintAudio_stfa = cookie_stfa;
   21.56 +
   21.57 +    DEBUG_PRINT((DEBUG_NAME "STFA audio available!\n"));
   21.58 +
   21.59      /* Set the function pointers */
   21.60      impl->OpenDevice = MINTSTFA_OpenDevice;
   21.61      impl->CloseDevice = MINTSTFA_CloseDevice;
   21.62 @@ -301,8 +296,7 @@
   21.63  }
   21.64  
   21.65  AudioBootStrap MINTAUDIO_STFA_bootstrap = {
   21.66 -    MINT_AUDIO_DRIVER_NAME, "MiNT STFA audio driver",
   21.67 -    MINTSTFA_Available, MINTSTFA_Init, 0
   21.68 +    MINT_AUDIO_DRIVER_NAME, "MiNT STFA audio driver", MINTSTFA_Init, 0
   21.69  };
   21.70  
   21.71  /* vi: set ts=4 sw=4 expandtab: */
    22.1 --- a/src/audio/mint/SDL_mintaudio_xbios.c	Tue Oct 17 08:04:51 2006 +0000
    22.2 +++ b/src/audio/mint/SDL_mintaudio_xbios.c	Tue Oct 17 09:09:21 2006 +0000
    22.3 @@ -62,41 +62,6 @@
    22.4  
    22.5  static unsigned long cookie_snd = 0;
    22.6  
    22.7 -static int
    22.8 -MINTXBIOS_Available(void)
    22.9 -{
   22.10 -    unsigned long dummy = 0;
   22.11 -    /*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */
   22.12 -    SDL_MintAudio_mint_present = SDL_FALSE;
   22.13 -
   22.14 -    /* We can't use XBIOS in interrupt with Magic, don't know about thread */
   22.15 -    if (Getcookie(C_MagX, &dummy) == C_FOUND) {
   22.16 -        return (0);
   22.17 -    }
   22.18 -
   22.19 -    /* Cookie _SND present ? if not, assume ST machine */
   22.20 -    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   22.21 -        cookie_snd = SND_PSG;
   22.22 -    }
   22.23 -
   22.24 -    /* Check if we have 16 bits audio */
   22.25 -    if ((cookie_snd & SND_16BIT) == 0) {
   22.26 -        DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n"));
   22.27 -        return (0);
   22.28 -    }
   22.29 -
   22.30 -    /* Check if audio is lockable */
   22.31 -    if (Locksnd() != 1) {
   22.32 -        DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n"));
   22.33 -        return (0);
   22.34 -    }
   22.35 -
   22.36 -    Unlocksnd();
   22.37 -
   22.38 -    DEBUG_PRINT((DEBUG_NAME "XBIOS audio available!\n"));
   22.39 -    return (1);
   22.40 -}
   22.41 -
   22.42  static void
   22.43  MINTXBIOS_LockDevice(_THIS)
   22.44  {
   22.45 @@ -481,6 +446,36 @@
   22.46  static int
   22.47  MINTXBIOS_Init(SDL_AudioDriverImpl *impl)
   22.48  {
   22.49 +    unsigned long dummy = 0;
   22.50 +    /*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */
   22.51 +    SDL_MintAudio_mint_present = SDL_FALSE;
   22.52 +
   22.53 +    /* We can't use XBIOS in interrupt with Magic, don't know about thread */
   22.54 +    if (Getcookie(C_MagX, &dummy) == C_FOUND) {
   22.55 +        return (0);
   22.56 +    }
   22.57 +
   22.58 +    /* Cookie _SND present ? if not, assume ST machine */
   22.59 +    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   22.60 +        cookie_snd = SND_PSG;
   22.61 +    }
   22.62 +
   22.63 +    /* Check if we have 16 bits audio */
   22.64 +    if ((cookie_snd & SND_16BIT) == 0) {
   22.65 +        SDL_SetError(DEBUG_NAME "no 16-bit sound");
   22.66 +        return (0);
   22.67 +    }
   22.68 +
   22.69 +    /* Check if audio is lockable */
   22.70 +    if (Locksnd() != 1) {
   22.71 +        SDL_SetError(DEBUG_NAME "audio locked by other application");
   22.72 +        return (0);
   22.73 +    }
   22.74 +
   22.75 +    Unlocksnd();
   22.76 +
   22.77 +    DEBUG_PRINT((DEBUG_NAME "XBIOS audio available!\n"));
   22.78 +
   22.79      /* Set the function pointers */
   22.80      impl->OpenDevice = MINTXBIOS_OpenDevice;
   22.81      impl->CloseDevice = MINTXBIOS_CloseDevice;
   22.82 @@ -494,8 +489,7 @@
   22.83  }
   22.84  
   22.85  AudioBootStrap MINTAUDIO_XBIOS_bootstrap = {
   22.86 -    MINT_AUDIO_DRIVER_NAME, "MiNT XBIOS audio driver",
   22.87 -    MINTXBIOS_Available, MINTXBIOS_Init, 0
   22.88 +    MINT_AUDIO_DRIVER_NAME, "MiNT XBIOS audio driver", MINTXBIOS_Init, 0
   22.89  };
   22.90  
   22.91  /* vi: set ts=4 sw=4 expandtab: */
    23.1 --- a/src/audio/mme/SDL_mmeaudio.c	Tue Oct 17 08:04:51 2006 +0000
    23.2 +++ b/src/audio/mme/SDL_mmeaudio.c	Tue Oct 17 09:09:21 2006 +0000
    23.3 @@ -31,12 +31,6 @@
    23.4  
    23.5  static BOOL inUse[NUM_BUFFERS];
    23.6  
    23.7 -static int
    23.8 -MME_Available(void)
    23.9 -{
   23.10 -    return 1;
   23.11 -}
   23.12 -
   23.13  static void
   23.14  SetMMerror(char *function, MMRESULT code)
   23.15  {
   23.16 @@ -260,8 +254,7 @@
   23.17  
   23.18  /* !!! FIXME: Windows "windib" driver is called waveout, too */
   23.19  AudioBootStrap MMEAUDIO_bootstrap = {
   23.20 -    "waveout", "Tru64 MME WaveOut",
   23.21 -    MME_Available, MME_Init, 0
   23.22 +    "waveout", "Tru64 MME WaveOut", MME_Init, 0
   23.23  };
   23.24  
   23.25  /* vi: set ts=4 sw=4 expandtab: */
    24.1 --- a/src/audio/nas/SDL_nasaudio.c	Tue Oct 17 08:04:51 2006 +0000
    24.2 +++ b/src/audio/nas/SDL_nasaudio.c	Tue Oct 17 09:09:21 2006 +0000
    24.3 @@ -97,12 +97,10 @@
    24.4  
    24.5  #ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC
    24.6  
    24.7 -static int library_load_count = 0;
    24.8 -
    24.9  static void
   24.10  UnloadNASLibrary(void)
   24.11  {
   24.12 -    if ((nas_handle != NULL) && (--library_load_count == 0)) {
   24.13 +    if (nas_handle != NULL) {
   24.14          SDL_UnloadObject(nas_handle);
   24.15          nas_handle = NULL;
   24.16      }
   24.17 @@ -112,7 +110,7 @@
   24.18  LoadNASLibrary(void)
   24.19  {
   24.20      int retval = 0;
   24.21 -    if (library_load_count++ == 0) {
   24.22 +    if (nas_handle == NULL) {
   24.23          nas_handle = SDL_LoadObject(nas_library);
   24.24          if (nas_handle == NULL) {
   24.25              /* Copy error string so we can use it in a new SDL_SetError(). */
   24.26 @@ -120,8 +118,6 @@
   24.27              size_t len = SDL_strlen(origerr) + 1;
   24.28              char *err = (char *) alloca(len);
   24.29              SDL_strlcpy(err, origerr, len);
   24.30 -
   24.31 -            library_load_count--;
   24.32              retval = -1;
   24.33              SDL_SetError("NAS: SDL_LoadObject('%s') failed: %s\n",
   24.34                            nas_library, err);
   24.35 @@ -151,21 +147,6 @@
   24.36  
   24.37  #endif /* SDL_AUDIO_DRIVER_NAS_DYNAMIC */
   24.38  
   24.39 -static int
   24.40 -NAS_Available(void)
   24.41 -{
   24.42 -    int available = 0;
   24.43 -    if (LoadNASLibrary() >= 0) {
   24.44 -        AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL);
   24.45 -        if (aud != NULL) {
   24.46 -            available = 1;
   24.47 -            NAS_AuCloseServer(aud);
   24.48 -        }
   24.49 -        UnloadNASLibrary();
   24.50 -    }
   24.51 -    return available;
   24.52 -}
   24.53 -
   24.54  /* This function waits until it is possible to write a full sound buffer */
   24.55  static void
   24.56  NAS_WaitDevice(_THIS)
   24.57 @@ -223,7 +204,6 @@
   24.58          }
   24.59          SDL_free(this->hidden);
   24.60          this2 = this->hidden = NULL;
   24.61 -        UnloadNASLibrary();
   24.62      }
   24.63  }
   24.64  
   24.65 @@ -316,11 +296,6 @@
   24.66      }
   24.67      SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   24.68  
   24.69 -    if (LoadNASLibrary() < 0) {
   24.70 -        NAS_CloseDevice(this);
   24.71 -        return 0;
   24.72 -    }
   24.73 -
   24.74      /* Try for a closest match on audio format */
   24.75      format = 0;
   24.76      for (test_format = SDL_FirstAudioFormat(this->spec.format);
   24.77 @@ -390,23 +365,40 @@
   24.78      return 1;
   24.79  }
   24.80  
   24.81 +static void
   24.82 +NAS_Deinitialize(void)
   24.83 +{
   24.84 +    UnloadNASLibrary();
   24.85 +}
   24.86 +
   24.87  static int
   24.88  NAS_Init(SDL_AudioDriverImpl *impl)
   24.89  {
   24.90 +    if (LoadNASLibrary() < 0) {
   24.91 +        return 0;
   24.92 +    } else {
   24.93 +        AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL);
   24.94 +        if (aud == NULL) {
   24.95 +            SDL_SetError("NAS: AuOpenServer() failed (no audio server?)");
   24.96 +            return 0;
   24.97 +        }
   24.98 +        NAS_AuCloseServer(aud);
   24.99 +    }
  24.100 +
  24.101      /* Set the function pointers */
  24.102      impl->OpenDevice = NAS_OpenDevice;
  24.103      impl->PlayDevice = NAS_PlayDevice;
  24.104      impl->WaitDevice = NAS_WaitDevice;
  24.105      impl->GetDeviceBuf = NAS_GetDeviceBuf;
  24.106      impl->CloseDevice = NAS_CloseDevice;
  24.107 +    impl->Deinitialize = NAS_Deinitialize;
  24.108      impl->OnlyHasDefaultOutputDevice = 1;  /* !!! FIXME: is this true? */
  24.109  
  24.110      return 1;
  24.111  }
  24.112  
  24.113  AudioBootStrap NAS_bootstrap = {
  24.114 -    NAS_DRIVER_NAME, "Network Audio System",
  24.115 -    NAS_Available, NAS_Init, 0
  24.116 +    NAS_DRIVER_NAME, "Network Audio System", NAS_Init, 0
  24.117  };
  24.118  
  24.119  /* vi: set ts=4 sw=4 expandtab: */
    25.1 --- a/src/audio/nto/SDL_nto_audio.c	Tue Oct 17 08:04:51 2006 +0000
    25.2 +++ b/src/audio/nto/SDL_nto_audio.c	Tue Oct 17 09:09:21 2006 +0000
    25.3 @@ -129,26 +129,6 @@
    25.4      cpars->buf.block.frags_max = DEFAULT_CPARAMS_FRAGS_MAX;
    25.5  }
    25.6  
    25.7 -static int
    25.8 -NTO_Available(void)
    25.9 -{
   25.10 -    /*  See if we can open a nonblocking channel.
   25.11 -       Return value '1' means we can.
   25.12 -       Return value '0' means we cannot. */
   25.13 -
   25.14 -    int available = 0;
   25.15 -    snd_pcm_t *handle = NULL;
   25.16 -    int rval = snd_pcm_open_preferred(&handle, NULL, NULL, OPEN_FLAGS);
   25.17 -    if (rval >= 0) {
   25.18 -        available = 1;
   25.19 -        if ((rval = snd_pcm_close(handle)) < 0) {
   25.20 -            available = 0;
   25.21 -        }
   25.22 -    }
   25.23 -
   25.24 -    return (available);
   25.25 -}
   25.26 -
   25.27  
   25.28  /* This function waits until it is possible to write a full sound buffer */
   25.29  static void
   25.30 @@ -452,6 +432,18 @@
   25.31  static int
   25.32  NTO_Init(SDL_AudioDriverImpl *impl)
   25.33  {
   25.34 +    /*  See if we can open a nonblocking channel. */
   25.35 +    snd_pcm_t *handle = NULL;
   25.36 +    int rval = snd_pcm_open_preferred(&handle, NULL, NULL, OPEN_FLAGS);
   25.37 +    if (rval < 0) {
   25.38 +        SDL_SetError("NTO: couldn't open preferred audio device");
   25.39 +        return 0;
   25.40 +    }
   25.41 +    if ((rval = snd_pcm_close(handle)) < 0) {
   25.42 +        SDL_SetError("NTO: couldn't close test audio device");
   25.43 +        return 0;
   25.44 +    }
   25.45 +
   25.46      /* Set the function pointers */
   25.47      impl->OpenDevice = NTO_OpenDevice;
   25.48      impl->ThreadInit = NTO_ThreadInit;
   25.49 @@ -465,8 +457,7 @@
   25.50  }
   25.51  
   25.52  AudioBootStrap QNXNTOAUDIO_bootstrap = {
   25.53 -    DRIVER_NAME, "QNX6 QSA-NTO Audio",
   25.54 -    NTO_AudioAvailable, NTO_Init, 0
   25.55 +    DRIVER_NAME, "QNX6 QSA-NTO Audio", NTO_Init, 0
   25.56  };
   25.57  
   25.58  /* vi: set ts=4 sw=4 expandtab: */
    26.1 --- a/src/audio/paudio/SDL_paudio.c	Tue Oct 17 08:04:51 2006 +0000
    26.2 +++ b/src/audio/paudio/SDL_paudio.c	Tue Oct 17 09:09:21 2006 +0000
    26.3 @@ -126,23 +126,6 @@
    26.4      return -1;
    26.5  }
    26.6  
    26.7 -
    26.8 -static int
    26.9 -PAUDIO_Available(void)
   26.10 -{
   26.11 -    int fd;
   26.12 -    int available;
   26.13 -
   26.14 -    available = 0;
   26.15 -    fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
   26.16 -    if (fd >= 0) {
   26.17 -        available = 1;
   26.18 -        close(fd);
   26.19 -    }
   26.20 -    return (available);
   26.21 -}
   26.22 -
   26.23 -
   26.24  /* This function waits until it is possible to write a full sound buffer */
   26.25  static void
   26.26  PAUDIO_WaitDevice(_THIS)
   26.27 @@ -543,6 +526,13 @@
   26.28  static int
   26.29  PAUDIO_Init(SDL_AudioDriverImpl *impl)
   26.30  {
   26.31 +    int fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
   26.32 +    if (fd < 0) {
   26.33 +        SDL_SetError("PAUDIO: Couldn't open audio device");
   26.34 +        return 0;
   26.35 +    }
   26.36 +    close(fd);
   26.37 +
   26.38      /* Set the function pointers */
   26.39      impl->OpenDevice = DSP_OpenDevice;
   26.40      impl->PlayDevice = DSP_PlayDevice;
   26.41 @@ -555,8 +545,7 @@
   26.42  }
   26.43  
   26.44  AudioBootStrap PAUDIO_bootstrap = {
   26.45 -    PAUDIO_DRIVER_NAME, "AIX Paudio",
   26.46 -    PAUDIO_Available, PAUDIO_Init, 0
   26.47 +    PAUDIO_DRIVER_NAME, "AIX Paudio", PAUDIO_Init, 0
   26.48  };
   26.49  
   26.50  /* vi: set ts=4 sw=4 expandtab: */
    27.1 --- a/src/audio/windib/SDL_dibaudio.c	Tue Oct 17 08:04:51 2006 +0000
    27.2 +++ b/src/audio/windib/SDL_dibaudio.c	Tue Oct 17 09:09:21 2006 +0000
    27.3 @@ -43,12 +43,6 @@
    27.4  #define WINDOWS_OS_NAME "Win32"
    27.5  #endif
    27.6  
    27.7 -static int
    27.8 -WINWAVEOUT_Available(void)
    27.9 -{
   27.10 -    return 1;   /* Always available on win32/pocketpc systems... */
   27.11 -}
   27.12 -
   27.13  /* The Win32 callback for filling the WAVE device */
   27.14  static void CALLBACK
   27.15  FillSound(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
   27.16 @@ -336,8 +330,7 @@
   27.17  }
   27.18  
   27.19  AudioBootStrap WINWAVEOUT_bootstrap = {
   27.20 -    "waveout", WINDOWS_OS_NAME " WaveOut",
   27.21 -    WINWAVEOUT_Available, WINWAVEOUT_Init, 0
   27.22 +    "waveout", WINDOWS_OS_NAME " WaveOut", WINWAVEOUT_Init, 0
   27.23  };
   27.24  
   27.25  /* vi: set ts=4 sw=4 expandtab: */
    28.1 --- a/src/audio/windx5/SDL_dx5audio.c	Tue Oct 17 08:04:51 2006 +0000
    28.2 +++ b/src/audio/windx5/SDL_dx5audio.c	Tue Oct 17 09:09:21 2006 +0000
    28.3 @@ -88,37 +88,6 @@
    28.4  }
    28.5  
    28.6  
    28.7 -
    28.8 -
    28.9 -static int
   28.10 -DSOUND_Available(void)
   28.11 -{
   28.12 -    int dsound_ok = 1;
   28.13 -    OSVERSIONINFO ver;
   28.14 -
   28.15 -    /*
   28.16 -     * Unfortunately, the sound drivers on NT have higher latencies than the
   28.17 -     *  audio buffers used by many SDL applications, so there are gaps in the
   28.18 -     *  audio - it sounds terrible.  Punt for now.
   28.19 -     */
   28.20 -    SDL_memset(&ver, '\0', sizeof (OSVERSIONINFO));
   28.21 -    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
   28.22 -    GetVersionEx(&ver);
   28.23 -    if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT)
   28.24 -        if (ver.dwMajorVersion <= 4) {
   28.25 -            dsound_ok = 0;  /* NT4.0 or earlier. Disable dsound support. */
   28.26 -        }
   28.27 -    }
   28.28 -
   28.29 -    if (dsound_ok) {
   28.30 -        dsound_ok = DSOUND_Load();  /* make sure we really have DX5. */
   28.31 -        DSOUND_Unload();
   28.32 -    }
   28.33 -
   28.34 -    return (dsound_ok);
   28.35 -}
   28.36 -
   28.37 -
   28.38  static void
   28.39  SetDSerror(const char *function, int code)
   28.40  {
   28.41 @@ -506,8 +475,23 @@
   28.42  static int
   28.43  DSOUND_Init(SDL_AudioDriverImpl *impl)
   28.44  {
   28.45 -    /* Load DirectX */
   28.46 -    if (DSOUND_Load() < 0) {
   28.47 +    OSVERSIONINFO ver;
   28.48 +
   28.49 +    /*
   28.50 +     * Unfortunately, the sound drivers on NT have higher latencies than the
   28.51 +     *  audio buffers used by many SDL applications, so there are gaps in the
   28.52 +     *  audio - it sounds terrible.  Punt for now.
   28.53 +     */
   28.54 +    SDL_memset(&ver, '\0', sizeof (OSVERSIONINFO));
   28.55 +    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
   28.56 +    GetVersionEx(&ver);
   28.57 +    if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT)
   28.58 +        if (ver.dwMajorVersion <= 4) {
   28.59 +            return 0;  /* NT4.0 or earlier. Disable dsound support. */
   28.60 +        }
   28.61 +    }
   28.62 +
   28.63 +    if (!DSOUND_Load()) {
   28.64          return 0;
   28.65      }
   28.66  
   28.67 @@ -526,8 +510,7 @@
   28.68  }
   28.69  
   28.70  AudioBootStrap DSOUND_bootstrap = {
   28.71 -    "dsound", WINDOWS_OS_NAME "DirectSound",
   28.72 -    DSOUND_Available, DSOUND_Init, 0
   28.73 +    "dsound", WINDOWS_OS_NAME "DirectSound", DSOUND_Init, 0
   28.74  };
   28.75  
   28.76  /* vi: set ts=4 sw=4 expandtab: */