Only initialize audio drivers that have been requested

If testautomation is running with only a specific audio driver enabled, we shouldn't try to open other ones, as they might fail.

Fixes https://github.com/libsdl-org/SDL/issues/8797

(cherry picked from commit 4c11307a4e75fbfde0d8ace6b19d612d2973bf0b)
main
Sam Lantinga 2024-01-08 13:38:29 -08:00
parent 590d0bec6f
commit ccae9c1ef6
1 changed files with 15 additions and 0 deletions

View File

@ -87,6 +87,7 @@ static int audio_initQuitAudio(void *arg)
int result; int result;
int i, iMax; int i, iMax;
const char *audioDriver; const char *audioDriver;
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_DRIVER);
/* Stop SDL audio subsystem */ /* Stop SDL audio subsystem */
SDL_QuitSubSystem(SDL_INIT_AUDIO); SDL_QuitSubSystem(SDL_INIT_AUDIO);
@ -102,6 +103,10 @@ static int audio_initQuitAudio(void *arg)
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL"); SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
if (hint && SDL_strcmp(audioDriver, hint) != 0) {
continue;
}
/* Call Init */ /* Call Init */
SDL_SetHint("SDL_AUDIO_DRIVER", audioDriver); SDL_SetHint("SDL_AUDIO_DRIVER", audioDriver);
result = SDL_InitSubSystem(SDL_INIT_AUDIO); result = SDL_InitSubSystem(SDL_INIT_AUDIO);
@ -146,6 +151,7 @@ static int audio_initOpenCloseQuitAudio(void *arg)
int i, iMax, j, k; int i, iMax, j, k;
const char *audioDriver; const char *audioDriver;
SDL_AudioSpec desired; SDL_AudioSpec desired;
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_DRIVER);
/* Stop SDL audio subsystem */ /* Stop SDL audio subsystem */
SDL_QuitSubSystem(SDL_INIT_AUDIO); SDL_QuitSubSystem(SDL_INIT_AUDIO);
@ -161,6 +167,10 @@ static int audio_initOpenCloseQuitAudio(void *arg)
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL"); SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
if (hint && SDL_strcmp(audioDriver, hint) != 0) {
continue;
}
/* Change specs */ /* Change specs */
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
@ -231,6 +241,7 @@ static int audio_pauseUnpauseAudio(void *arg)
int result; int result;
const char *audioDriver; const char *audioDriver;
SDL_AudioSpec desired; SDL_AudioSpec desired;
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_DRIVER);
/* Stop SDL audio subsystem */ /* Stop SDL audio subsystem */
SDL_QuitSubSystem(SDL_INIT_AUDIO); SDL_QuitSubSystem(SDL_INIT_AUDIO);
@ -246,6 +257,10 @@ static int audio_pauseUnpauseAudio(void *arg)
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL"); SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
if (hint && SDL_strcmp(audioDriver, hint) != 0) {
continue;
}
/* Change specs */ /* Change specs */
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {