diff src/audio/SDL_audio.c @ 3804:b12b7ec0dfcc SDL-ryan-multiple-audio-device

Removed an if (), which lets this code section be a little less cluttered...
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 04 Oct 2006 22:16:46 +0000
parents 3decf9cdeb63
children 1485d42cf1a0
line wrap: on
line diff
--- a/src/audio/SDL_audio.c	Wed Oct 04 22:10:09 2006 +0000
+++ b/src/audio/SDL_audio.c	Wed Oct 04 22:16:46 2006 +0000
@@ -375,40 +375,39 @@
         driver_name = SDL_getenv("SDL_AUDIODRIVER");
     }
 
-    if (!initialized) {
-        if (driver_name != NULL) {
-            for (i = 0; bootstrap[i]; ++i) {
-                if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
-                    if (bootstrap[i]->available()) {
-                        SDL_memset(&current_audio, 0, sizeof (current_audio));
-                        current_audio.name = bootstrap[i]->name;
-                        current_audio.desc = bootstrap[i]->desc;
-                        initialized = bootstrap[i]->init(&current_audio.impl);
-                    }
-                    break;
-                }
-            }
-        } else {
-            for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
-                if ((!bootstrap[i]->demand) && (bootstrap[i]->available())) {
+    if (driver_name != NULL) {
+        for (i = 0; bootstrap[i]; ++i) {
+            if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
+                if (bootstrap[i]->available()) {
                     SDL_memset(&current_audio, 0, sizeof (current_audio));
                     current_audio.name = bootstrap[i]->name;
                     current_audio.desc = bootstrap[i]->desc;
                     initialized = bootstrap[i]->init(&current_audio.impl);
                 }
+                break;
             }
         }
-        if (!initialized) {
-            if (driver_name) {
-                SDL_SetError("%s not available", driver_name);
-            } else {
-                SDL_SetError("No available audio device");
+    } else {
+        for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
+            if ((!bootstrap[i]->demand_only) && (bootstrap[i]->available())) {
+                SDL_memset(&current_audio, 0, sizeof (current_audio));
+                current_audio.name = bootstrap[i]->name;
+                current_audio.desc = bootstrap[i]->desc;
+                initialized = bootstrap[i]->init(&current_audio.impl);
             }
-            SDL_memset(&current_audio, 0, sizeof (current_audio));
-            return (-1);  /* No driver was available, so fail. */
         }
     }
 
+    if (!initialized) {
+        if (driver_name) {
+            SDL_SetError("%s not available", driver_name);
+        } else {
+            SDL_SetError("No available audio device");
+        }
+        SDL_memset(&current_audio, 0, sizeof (current_audio));
+        return (-1);  /* No driver was available, so fail. */
+    }
+
     finalize_audio_entry_points();
 
     return (0);