From 4da045d0d307669e9cf338022a2e013c9d00fac0 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 4 Oct 2006 22:16:46 +0000 Subject: [PATCH] Removed an if (), which lets this code section be a little less cluttered... --- src/audio/SDL_audio.c | 45 ++++++++++++++++++++-------------------- src/audio/SDL_sysaudio.h | 2 +- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index c9cee7e59..300820430 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -375,40 +375,39 @@ SDL_AudioInit(const char *driver_name) 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(¤t_audio, 0, sizeof (current_audio)); - current_audio.name = bootstrap[i]->name; - current_audio.desc = bootstrap[i]->desc; - initialized = bootstrap[i]->init(¤t_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(¤t_audio, 0, sizeof (current_audio)); current_audio.name = bootstrap[i]->name; current_audio.desc = bootstrap[i]->desc; initialized = bootstrap[i]->init(¤t_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(¤t_audio, 0, sizeof (current_audio)); + current_audio.name = bootstrap[i]->name; + current_audio.desc = bootstrap[i]->desc; + initialized = bootstrap[i]->init(¤t_audio.impl); } - SDL_memset(¤t_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(¤t_audio, 0, sizeof (current_audio)); + return (-1); /* No driver was available, so fail. */ + } + finalize_audio_entry_points(); return (0); diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 3652942b9..b1663f215 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -109,7 +109,7 @@ typedef struct AudioBootStrap const char *desc; int (*available) (void); int (*init) (SDL_AudioDriverImpl *impl); - int demand:1; /* 1==must request explicitly, or it won't be available. */ + int demand_only:1; /* 1==request explicitly, or it won't be available. */ } AudioBootStrap; #endif /* _SDL_sysaudio_h */