Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Removed an if (), which lets this code section be a little less clutt…
Browse files Browse the repository at this point in the history
…ered...
  • Loading branch information
icculus committed Oct 4, 2006
1 parent bba2160 commit 4da045d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
45 changes: 22 additions & 23 deletions src/audio/SDL_audio.c
Expand Up @@ -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(&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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/SDL_sysaudio.h
Expand Up @@ -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 */
Expand Down

0 comments on commit 4da045d

Please sign in to comment.