Commit 0bd0f133 authored by Sam Lantinga's avatar Sam Lantinga

Look at environment variables in SDL_VideoInit() and SDL_AudioInit()

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401954
parent a73c4902
......@@ -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;
......@@ -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;
......
......@@ -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
......@@ -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) {
......@@ -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
}
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment