Browse Source

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
Sam Lantinga 1 year ago
parent
commit
4c11307a4e
1 changed files with 15 additions and 0 deletions
  1. 15 0
      test/testautomation_audio.c

+ 15 - 0
test/testautomation_audio.c

@@ -83,6 +83,7 @@ int audio_initQuitAudio()
     int result;
     int i, iMax;
     const char *audioDriver;
+    const char *hint = SDL_GetHint(SDL_HINT_AUDIODRIVER);
 
     /* Stop SDL audio subsystem */
     SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -98,6 +99,10 @@ int audio_initQuitAudio()
         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 */
 
+        if (hint && SDL_strcmp(audioDriver, hint) != 0) {
+            continue;
+        }
+
         /* Call Init */
         result = SDL_AudioInit(audioDriver);
         SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
@@ -140,6 +145,7 @@ int audio_initOpenCloseQuitAudio()
     int i, iMax, j, k;
     const char *audioDriver;
     SDL_AudioSpec desired;
+    const char *hint = SDL_GetHint(SDL_HINT_AUDIODRIVER);
 
     /* Stop SDL audio subsystem */
     SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -155,6 +161,10 @@ int audio_initOpenCloseQuitAudio()
         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 */
 
+        if (hint && SDL_strcmp(audioDriver, hint) != 0) {
+            continue;
+        }
+
         /* Change specs */
         for (j = 0; j < 2; j++) {
 
@@ -229,6 +239,7 @@ int audio_pauseUnpauseAudio()
     int originalCounter;
     const char *audioDriver;
     SDL_AudioSpec desired;
+    const char *hint = SDL_GetHint(SDL_HINT_AUDIODRIVER);
 
     /* Stop SDL audio subsystem */
     SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -244,6 +255,10 @@ int audio_pauseUnpauseAudio()
         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 */
 
+        if (hint && SDL_strcmp(audioDriver, hint) != 0) {
+            continue;
+        }
+
         /* Change specs */
         for (j = 0; j < 2; j++) {