diff src/audio/mint/SDL_mintaudio_xbios.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 1f156fd874fa
children
line wrap: on
line diff
--- a/src/audio/mint/SDL_mintaudio_xbios.c	Tue Oct 17 08:04:51 2006 +0000
+++ b/src/audio/mint/SDL_mintaudio_xbios.c	Tue Oct 17 09:09:21 2006 +0000
@@ -62,41 +62,6 @@
 
 static unsigned long cookie_snd = 0;
 
-static int
-MINTXBIOS_Available(void)
-{
-    unsigned long dummy = 0;
-    /*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */
-    SDL_MintAudio_mint_present = SDL_FALSE;
-
-    /* We can't use XBIOS in interrupt with Magic, don't know about thread */
-    if (Getcookie(C_MagX, &dummy) == C_FOUND) {
-        return (0);
-    }
-
-    /* Cookie _SND present ? if not, assume ST machine */
-    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
-        cookie_snd = SND_PSG;
-    }
-
-    /* Check if we have 16 bits audio */
-    if ((cookie_snd & SND_16BIT) == 0) {
-        DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n"));
-        return (0);
-    }
-
-    /* Check if audio is lockable */
-    if (Locksnd() != 1) {
-        DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n"));
-        return (0);
-    }
-
-    Unlocksnd();
-
-    DEBUG_PRINT((DEBUG_NAME "XBIOS audio available!\n"));
-    return (1);
-}
-
 static void
 MINTXBIOS_LockDevice(_THIS)
 {
@@ -481,6 +446,36 @@
 static int
 MINTXBIOS_Init(SDL_AudioDriverImpl *impl)
 {
+    unsigned long dummy = 0;
+    /*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */
+    SDL_MintAudio_mint_present = SDL_FALSE;
+
+    /* We can't use XBIOS in interrupt with Magic, don't know about thread */
+    if (Getcookie(C_MagX, &dummy) == C_FOUND) {
+        return (0);
+    }
+
+    /* Cookie _SND present ? if not, assume ST machine */
+    if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
+        cookie_snd = SND_PSG;
+    }
+
+    /* Check if we have 16 bits audio */
+    if ((cookie_snd & SND_16BIT) == 0) {
+        SDL_SetError(DEBUG_NAME "no 16-bit sound");
+        return (0);
+    }
+
+    /* Check if audio is lockable */
+    if (Locksnd() != 1) {
+        SDL_SetError(DEBUG_NAME "audio locked by other application");
+        return (0);
+    }
+
+    Unlocksnd();
+
+    DEBUG_PRINT((DEBUG_NAME "XBIOS audio available!\n"));
+
     /* Set the function pointers */
     impl->OpenDevice = MINTXBIOS_OpenDevice;
     impl->CloseDevice = MINTXBIOS_CloseDevice;
@@ -494,8 +489,7 @@
 }
 
 AudioBootStrap MINTAUDIO_XBIOS_bootstrap = {
-    MINT_AUDIO_DRIVER_NAME, "MiNT XBIOS audio driver",
-    MINTXBIOS_Available, MINTXBIOS_Init, 0
+    MINT_AUDIO_DRIVER_NAME, "MiNT XBIOS audio driver", MINTXBIOS_Init, 0
 };
 
 /* vi: set ts=4 sw=4 expandtab: */