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

Commit

Permalink
Browse files Browse the repository at this point in the history
Look at environment variables in SDL_VideoInit() and SDL_AudioInit()
  • Loading branch information
slouken committed Jul 15, 2006
1 parent e087cb9 commit f8d13eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/SDL.c
Expand Up @@ -62,8 +62,7 @@ SDL_InitSubSystem(Uint32 flags)
#if !SDL_VIDEO_DISABLED
/* Initialize the video/event subsystem */
if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) {
if (SDL_VideoInit(SDL_getenv("SDL_VIDEODRIVER"),
(flags & SDL_INIT_EVENTTHREAD)) < 0) {
if (SDL_VideoInit(NULL, (flags & SDL_INIT_EVENTTHREAD)) < 0) {
return (-1);
}
SDL_initialized |= SDL_INIT_VIDEO;
Expand All @@ -78,7 +77,7 @@ SDL_InitSubSystem(Uint32 flags)
#if !SDL_AUDIO_DISABLED
/* Initialize the audio subsystem */
if ((flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO)) {
if (SDL_AudioInit(SDL_getenv("SDL_AUDIODRIVER")) < 0) {
if (SDL_AudioInit(NULL) < 0) {
return (-1);
}
SDL_initialized |= SDL_INIT_AUDIO;
Expand Down
15 changes: 7 additions & 8 deletions src/audio/SDL_audio.c
Expand Up @@ -361,6 +361,9 @@ SDL_AudioInit(const char *driver_name)
/* Select the proper audio driver */
audio = NULL;
idx = 0;
if (driver_name == NULL) {
driver_name = SDL_getenv("SDL_AUDIODRIVER");
}
#if SDL_AUDIO_DRIVER_ESD
if ((driver_name == NULL) && (SDL_getenv("ESPEAKER") != NULL)) {
/* Ahem, we know that if ESPEAKER is set, user probably wants
Expand Down Expand Up @@ -393,11 +396,6 @@ SDL_AudioInit(const char *driver_name)
#endif /* SDL_AUDIO_DRIVER_ESD */
if (audio == NULL) {
if (driver_name != NULL) {
#if 0 /* This will be replaced with a better driver selection API */
if (SDL_strrchr(driver_name, ':') != NULL) {
idx = atoi(SDL_strrchr(driver_name, ':') + 1);
}
#endif
for (i = 0; bootstrap[i]; ++i) {
if (SDL_strncmp(bootstrap[i]->name, driver_name,
SDL_strlen(bootstrap[i]->name)) == 0) {
Expand All @@ -423,9 +421,10 @@ SDL_AudioInit(const char *driver_name)
} else {
SDL_SetError("No available audio device");
}
#if 0 /* Don't fail SDL_Init() if audio isn't available.
SDL_OpenAudio() will handle it at that point. *sigh*
*/
#if 0
/* Don't fail SDL_Init() if audio isn't available.
SDL_OpenAudio() will handle it at that point. *sigh*
*/
return (-1);
#endif
}
Expand Down
3 changes: 3 additions & 0 deletions src/video/SDL_video.c
Expand Up @@ -201,6 +201,9 @@ SDL_VideoInit(const char *driver_name, Uint32 flags)
/* Select the proper video driver */
index = 0;
video = NULL;
if (driver_name == NULL) {
driver_name = SDL_getenv("SDL_VIDEODRIVER");
}
if (driver_name != NULL) {
for (i = 0; bootstrap[i]; ++i) {
if (SDL_strncmp(bootstrap[i]->name, driver_name,
Expand Down

0 comments on commit f8d13eb

Please sign in to comment.