diff src/audio/windx5/SDL_dx5audio.c @ 3846:66fb40445587 SDL-ryan-multiple-audio-device

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.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 17 Oct 2006 09:09:21 +0000
parents 6b04ca2f1016
children
line wrap: on
line diff
--- a/src/audio/windx5/SDL_dx5audio.c	Tue Oct 17 08:04:51 2006 +0000
+++ b/src/audio/windx5/SDL_dx5audio.c	Tue Oct 17 09:09:21 2006 +0000
@@ -88,37 +88,6 @@
 }
 
 
-
-
-static int
-DSOUND_Available(void)
-{
-    int dsound_ok = 1;
-    OSVERSIONINFO ver;
-
-    /*
-     * Unfortunately, the sound drivers on NT have higher latencies than the
-     *  audio buffers used by many SDL applications, so there are gaps in the
-     *  audio - it sounds terrible.  Punt for now.
-     */
-    SDL_memset(&ver, '\0', sizeof (OSVERSIONINFO));
-    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-    GetVersionEx(&ver);
-    if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT)
-        if (ver.dwMajorVersion <= 4) {
-            dsound_ok = 0;  /* NT4.0 or earlier. Disable dsound support. */
-        }
-    }
-
-    if (dsound_ok) {
-        dsound_ok = DSOUND_Load();  /* make sure we really have DX5. */
-        DSOUND_Unload();
-    }
-
-    return (dsound_ok);
-}
-
-
 static void
 SetDSerror(const char *function, int code)
 {
@@ -506,8 +475,23 @@
 static int
 DSOUND_Init(SDL_AudioDriverImpl *impl)
 {
-    /* Load DirectX */
-    if (DSOUND_Load() < 0) {
+    OSVERSIONINFO ver;
+
+    /*
+     * Unfortunately, the sound drivers on NT have higher latencies than the
+     *  audio buffers used by many SDL applications, so there are gaps in the
+     *  audio - it sounds terrible.  Punt for now.
+     */
+    SDL_memset(&ver, '\0', sizeof (OSVERSIONINFO));
+    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+    GetVersionEx(&ver);
+    if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT)
+        if (ver.dwMajorVersion <= 4) {
+            return 0;  /* NT4.0 or earlier. Disable dsound support. */
+        }
+    }
+
+    if (!DSOUND_Load()) {
         return 0;
     }
 
@@ -526,8 +510,7 @@
 }
 
 AudioBootStrap DSOUND_bootstrap = {
-    "dsound", WINDOWS_OS_NAME "DirectSound",
-    DSOUND_Available, DSOUND_Init, 0
+    "dsound", WINDOWS_OS_NAME "DirectSound", DSOUND_Init, 0
 };
 
 /* vi: set ts=4 sw=4 expandtab: */