Look at environment variables in SDL_VideoInit() and SDL_AudioInit()
authorSam Lantinga <slouken@libsdl.org>
Sat, 15 Jul 2006 19:30:18 +0000
changeset 19098f1ab2f7c722
parent 1908 e079dafea2bf
child 1910 c26194009c9c
Look at environment variables in SDL_VideoInit() and SDL_AudioInit()
src/SDL.c
src/audio/SDL_audio.c
src/video/SDL_video.c
     1.1 --- a/src/SDL.c	Sat Jul 15 19:29:42 2006 +0000
     1.2 +++ b/src/SDL.c	Sat Jul 15 19:30:18 2006 +0000
     1.3 @@ -62,8 +62,7 @@
     1.4  #if !SDL_VIDEO_DISABLED
     1.5      /* Initialize the video/event subsystem */
     1.6      if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) {
     1.7 -        if (SDL_VideoInit(SDL_getenv("SDL_VIDEODRIVER"),
     1.8 -                          (flags & SDL_INIT_EVENTTHREAD)) < 0) {
     1.9 +        if (SDL_VideoInit(NULL, (flags & SDL_INIT_EVENTTHREAD)) < 0) {
    1.10              return (-1);
    1.11          }
    1.12          SDL_initialized |= SDL_INIT_VIDEO;
    1.13 @@ -78,7 +77,7 @@
    1.14  #if !SDL_AUDIO_DISABLED
    1.15      /* Initialize the audio subsystem */
    1.16      if ((flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO)) {
    1.17 -        if (SDL_AudioInit(SDL_getenv("SDL_AUDIODRIVER")) < 0) {
    1.18 +        if (SDL_AudioInit(NULL) < 0) {
    1.19              return (-1);
    1.20          }
    1.21          SDL_initialized |= SDL_INIT_AUDIO;
     2.1 --- a/src/audio/SDL_audio.c	Sat Jul 15 19:29:42 2006 +0000
     2.2 +++ b/src/audio/SDL_audio.c	Sat Jul 15 19:30:18 2006 +0000
     2.3 @@ -361,6 +361,9 @@
     2.4      /* Select the proper audio driver */
     2.5      audio = NULL;
     2.6      idx = 0;
     2.7 +    if (driver_name == NULL) {
     2.8 +        driver_name = SDL_getenv("SDL_AUDIODRIVER");
     2.9 +    }
    2.10  #if SDL_AUDIO_DRIVER_ESD
    2.11      if ((driver_name == NULL) && (SDL_getenv("ESPEAKER") != NULL)) {
    2.12          /* Ahem, we know that if ESPEAKER is set, user probably wants
    2.13 @@ -393,11 +396,6 @@
    2.14  #endif /* SDL_AUDIO_DRIVER_ESD */
    2.15      if (audio == NULL) {
    2.16          if (driver_name != NULL) {
    2.17 -#if 0                           /* This will be replaced with a better driver selection API */
    2.18 -            if (SDL_strrchr(driver_name, ':') != NULL) {
    2.19 -                idx = atoi(SDL_strrchr(driver_name, ':') + 1);
    2.20 -            }
    2.21 -#endif
    2.22              for (i = 0; bootstrap[i]; ++i) {
    2.23                  if (SDL_strncmp(bootstrap[i]->name, driver_name,
    2.24                                  SDL_strlen(bootstrap[i]->name)) == 0) {
    2.25 @@ -423,9 +421,10 @@
    2.26              } else {
    2.27                  SDL_SetError("No available audio device");
    2.28              }
    2.29 -#if 0                           /* Don't fail SDL_Init() if audio isn't available.
    2.30 -                                   SDL_OpenAudio() will handle it at that point.  *sigh*
    2.31 -                                 */
    2.32 +#if 0
    2.33 +            /* Don't fail SDL_Init() if audio isn't available.
    2.34 +               SDL_OpenAudio() will handle it at that point.  *sigh*
    2.35 +             */
    2.36              return (-1);
    2.37  #endif
    2.38          }
     3.1 --- a/src/video/SDL_video.c	Sat Jul 15 19:29:42 2006 +0000
     3.2 +++ b/src/video/SDL_video.c	Sat Jul 15 19:30:18 2006 +0000
     3.3 @@ -201,6 +201,9 @@
     3.4      /* Select the proper video driver */
     3.5      index = 0;
     3.6      video = NULL;
     3.7 +    if (driver_name == NULL) {
     3.8 +        driver_name = SDL_getenv("SDL_VIDEODRIVER");
     3.9 +    }
    3.10      if (driver_name != NULL) {
    3.11          for (i = 0; bootstrap[i]; ++i) {
    3.12              if (SDL_strncmp(bootstrap[i]->name, driver_name,