Removed an if (), which lets this code section be a little less cluttered... SDL-ryan-multiple-audio-device
authorRyan C. Gordon
Wed, 04 Oct 2006 22:16:46 +0000
branchSDL-ryan-multiple-audio-device
changeset 3804b12b7ec0dfcc
parent 3803 3decf9cdeb63
child 3805 ef7f7be318da
Removed an if (), which lets this code section be a little less cluttered...
src/audio/SDL_audio.c
src/audio/SDL_sysaudio.h
     1.1 --- a/src/audio/SDL_audio.c	Wed Oct 04 22:10:09 2006 +0000
     1.2 +++ b/src/audio/SDL_audio.c	Wed Oct 04 22:16:46 2006 +0000
     1.3 @@ -375,40 +375,39 @@
     1.4          driver_name = SDL_getenv("SDL_AUDIODRIVER");
     1.5      }
     1.6  
     1.7 -    if (!initialized) {
     1.8 -        if (driver_name != NULL) {
     1.9 -            for (i = 0; bootstrap[i]; ++i) {
    1.10 -                if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
    1.11 -                    if (bootstrap[i]->available()) {
    1.12 -                        SDL_memset(&current_audio, 0, sizeof (current_audio));
    1.13 -                        current_audio.name = bootstrap[i]->name;
    1.14 -                        current_audio.desc = bootstrap[i]->desc;
    1.15 -                        initialized = bootstrap[i]->init(&current_audio.impl);
    1.16 -                    }
    1.17 -                    break;
    1.18 -                }
    1.19 -            }
    1.20 -        } else {
    1.21 -            for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
    1.22 -                if ((!bootstrap[i]->demand) && (bootstrap[i]->available())) {
    1.23 +    if (driver_name != NULL) {
    1.24 +        for (i = 0; bootstrap[i]; ++i) {
    1.25 +            if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
    1.26 +                if (bootstrap[i]->available()) {
    1.27                      SDL_memset(&current_audio, 0, sizeof (current_audio));
    1.28                      current_audio.name = bootstrap[i]->name;
    1.29                      current_audio.desc = bootstrap[i]->desc;
    1.30                      initialized = bootstrap[i]->init(&current_audio.impl);
    1.31                  }
    1.32 +                break;
    1.33              }
    1.34          }
    1.35 -        if (!initialized) {
    1.36 -            if (driver_name) {
    1.37 -                SDL_SetError("%s not available", driver_name);
    1.38 -            } else {
    1.39 -                SDL_SetError("No available audio device");
    1.40 +    } else {
    1.41 +        for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
    1.42 +            if ((!bootstrap[i]->demand_only) && (bootstrap[i]->available())) {
    1.43 +                SDL_memset(&current_audio, 0, sizeof (current_audio));
    1.44 +                current_audio.name = bootstrap[i]->name;
    1.45 +                current_audio.desc = bootstrap[i]->desc;
    1.46 +                initialized = bootstrap[i]->init(&current_audio.impl);
    1.47              }
    1.48 -            SDL_memset(&current_audio, 0, sizeof (current_audio));
    1.49 -            return (-1);  /* No driver was available, so fail. */
    1.50          }
    1.51      }
    1.52  
    1.53 +    if (!initialized) {
    1.54 +        if (driver_name) {
    1.55 +            SDL_SetError("%s not available", driver_name);
    1.56 +        } else {
    1.57 +            SDL_SetError("No available audio device");
    1.58 +        }
    1.59 +        SDL_memset(&current_audio, 0, sizeof (current_audio));
    1.60 +        return (-1);  /* No driver was available, so fail. */
    1.61 +    }
    1.62 +
    1.63      finalize_audio_entry_points();
    1.64  
    1.65      return (0);
     2.1 --- a/src/audio/SDL_sysaudio.h	Wed Oct 04 22:10:09 2006 +0000
     2.2 +++ b/src/audio/SDL_sysaudio.h	Wed Oct 04 22:16:46 2006 +0000
     2.3 @@ -109,7 +109,7 @@
     2.4      const char *desc;
     2.5      int (*available) (void);
     2.6      int (*init) (SDL_AudioDriverImpl *impl);
     2.7 -    int demand:1;  /* 1==must request explicitly, or it won't be available. */
     2.8 +    int demand_only:1;  /* 1==request explicitly, or it won't be available. */
     2.9  } AudioBootStrap;
    2.10  
    2.11  #endif /* _SDL_sysaudio_h */