mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 19:35:39 +00:00
Support comma-separated lists in SDL_AUDIODRIVER
This commit is contained in:
parent
5ec69285fa
commit
45de0a1d13
|
@ -972,19 +972,38 @@ SDL_AudioInit(const char *driver_name)
|
||||||
driver_name = SDL_getenv("SDL_AUDIODRIVER");
|
driver_name = SDL_getenv("SDL_AUDIODRIVER");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (driver_name != NULL) {
|
||||||
|
const char *driver_attempt = driver_name;
|
||||||
|
while (driver_attempt != NULL && *driver_attempt != 0 && !initialized) {
|
||||||
|
const char *driver_attempt_end = SDL_strchr(driver_attempt, ',');
|
||||||
|
size_t driver_attempt_len = (driver_attempt_end != NULL) ? (driver_attempt_end - driver_attempt)
|
||||||
|
: SDL_strlen(driver_attempt);
|
||||||
|
|
||||||
|
for (i = 0; bootstrap[i]; ++i) {
|
||||||
|
if (SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0) {
|
||||||
|
tried_to_init = 1;
|
||||||
|
SDL_zero(current_audio);
|
||||||
|
current_audio.name = bootstrap[i]->name;
|
||||||
|
current_audio.desc = bootstrap[i]->desc;
|
||||||
|
initialized = bootstrap[i]->init(¤t_audio.impl);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
driver_attempt = (driver_attempt_end != NULL) ? (driver_attempt_end + 1) : NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
|
for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
|
||||||
/* make sure we should even try this driver before doing so... */
|
if(bootstrap[i]->demand_only) {
|
||||||
const AudioBootStrap *backend = bootstrap[i];
|
|
||||||
if ((driver_name && (SDL_strncasecmp(backend->name, driver_name, SDL_strlen(driver_name)) != 0)) ||
|
|
||||||
(!driver_name && backend->demand_only)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tried_to_init = 1;
|
tried_to_init = 1;
|
||||||
SDL_zero(current_audio);
|
SDL_zero(current_audio);
|
||||||
current_audio.name = backend->name;
|
current_audio.name = bootstrap[i]->name;
|
||||||
current_audio.desc = backend->desc;
|
current_audio.desc = bootstrap[i]->desc;
|
||||||
initialized = backend->init(¤t_audio.impl);
|
initialized = bootstrap[i]->init(¤t_audio.impl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
|
|
Loading…
Reference in a new issue