|
@@ -52,6 +52,42 @@ void SDLCALL _audio_testCallback(void *userdata, Uint8 *stream, int len)
|
|
|
_audio_testCallbackLength += len;
|
|
|
}
|
|
|
|
|
|
+#if defined(__linux__)
|
|
|
+/* Linux builds can include many audio drivers, but some are very
|
|
|
+ * obscure and typically unsupported on modern systems. They will
|
|
|
+ * be skipped in tests that run against all included drivers, as
|
|
|
+ * they are basically guaranteed to fail.
|
|
|
+ */
|
|
|
+static SDL_bool DriverIsProblematic(const char *driver)
|
|
|
+{
|
|
|
+ static const char *driverList[] = {
|
|
|
+ /* Omnipresent in Linux builds, but deprecated since 2002,
|
|
|
+ * very rarely used on Linux nowadays, and is almost certainly
|
|
|
+ * guaranteed to fail.
|
|
|
+ */
|
|
|
+ "dsp",
|
|
|
+
|
|
|
+ /* OpenBSD sound API. Can be used on Linux, but very rare. */
|
|
|
+ "sndio",
|
|
|
+
|
|
|
+ /* Always fails on initialization and/or opening a device.
|
|
|
+ * Does anyone or anything actually use this?
|
|
|
+ */
|
|
|
+ "nas"
|
|
|
+ };
|
|
|
+
|
|
|
+ int i;
|
|
|
+
|
|
|
+ for (i = 0; i < SDL_arraysize(driverList); ++i) {
|
|
|
+ if (SDL_strcmp(driver, driverList[i]) == 0) {
|
|
|
+ return SDL_TRUE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return SDL_FALSE;
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
/* Test case functions */
|
|
|
|
|
|
/**
|
|
@@ -89,15 +125,33 @@ int audio_initQuitAudio()
|
|
|
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
|
|
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
|
|
|
|
|
|
- /* Loop over all available audio drivers */
|
|
|
- iMax = SDL_GetNumAudioDrivers();
|
|
|
- SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
|
|
|
- SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
|
|
|
+ /* Was a specific driver requested? */
|
|
|
+ audioDriver = SDL_GetHint(SDL_HINT_AUDIODRIVER);
|
|
|
+
|
|
|
+ if (audioDriver == NULL) {
|
|
|
+ /* Loop over all available audio drivers */
|
|
|
+ iMax = SDL_GetNumAudioDrivers();
|
|
|
+ SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
|
|
|
+ SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
|
|
|
+ } else {
|
|
|
+ /* A specific driver was requested for testing */
|
|
|
+ iMax = 1;
|
|
|
+ }
|
|
|
for (i = 0; i < iMax; i++) {
|
|
|
- audioDriver = SDL_GetAudioDriver(i);
|
|
|
- SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
|
|
- 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 (audioDriver == NULL) {
|
|
|
+ audioDriver = SDL_GetAudioDriver(i);
|
|
|
+ SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
|
|
+ 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 defined(__linux__)
|
|
|
+ if (DriverIsProblematic(audioDriver)) {
|
|
|
+ SDLTest_Log("Audio driver '%s' flagged as problematic: skipping init/quit test (set SDL_AUDIODRIVER=%s to force)", audioDriver, audioDriver);
|
|
|
+ audioDriver = NULL;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+#endif
|
|
|
+ }
|
|
|
|
|
|
if (hint && SDL_strcmp(audioDriver, hint) != 0) {
|
|
|
continue;
|
|
@@ -111,6 +165,8 @@ int audio_initQuitAudio()
|
|
|
/* Call Quit */
|
|
|
SDL_AudioQuit();
|
|
|
SDLTest_AssertPass("Call to SDL_AudioQuit()");
|
|
|
+
|
|
|
+ audioDriver = NULL;
|
|
|
}
|
|
|
|
|
|
/* NULL driver specification */
|
|
@@ -151,15 +207,33 @@ int audio_initOpenCloseQuitAudio()
|
|
|
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
|
|
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
|
|
|
|
|
|
- /* Loop over all available audio drivers */
|
|
|
- iMax = SDL_GetNumAudioDrivers();
|
|
|
- SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
|
|
|
- SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
|
|
|
+ /* Was a specific driver requested? */
|
|
|
+ audioDriver = SDL_GetHint(SDL_HINT_AUDIODRIVER);
|
|
|
+
|
|
|
+ if (audioDriver == NULL) {
|
|
|
+ /* Loop over all available audio drivers */
|
|
|
+ iMax = SDL_GetNumAudioDrivers();
|
|
|
+ SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
|
|
|
+ SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
|
|
|
+ } else {
|
|
|
+ /* A specific driver was requested for testing */
|
|
|
+ iMax = 1;
|
|
|
+ }
|
|
|
for (i = 0; i < iMax; i++) {
|
|
|
- audioDriver = SDL_GetAudioDriver(i);
|
|
|
- SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
|
|
- 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 (audioDriver == NULL) {
|
|
|
+ audioDriver = SDL_GetAudioDriver(i);
|
|
|
+ SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
|
|
+ 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 defined(__linux__)
|
|
|
+ if (DriverIsProblematic(audioDriver)) {
|
|
|
+ SDLTest_Log("Audio driver '%s' flagged as problematic: skipping device open/close test (set SDL_AUDIODRIVER=%s to force)", audioDriver, audioDriver);
|
|
|
+ audioDriver = NULL;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+#endif
|
|
|
+ }
|
|
|
|
|
|
if (hint && SDL_strcmp(audioDriver, hint) != 0) {
|
|
|
continue;
|
|
@@ -173,6 +247,17 @@ int audio_initOpenCloseQuitAudio()
|
|
|
SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
|
|
|
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
|
|
|
|
|
|
+ /* Check for output devices */
|
|
|
+ result = SDL_GetNumAudioDevices(SDL_FALSE);
|
|
|
+ SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(SDL_FALSE)");
|
|
|
+ SDLTest_AssertCheck(result >= 0, "Validate result value; expected: >=0 got: %d", result);
|
|
|
+ if (result <= 0) {
|
|
|
+ SDLTest_Log("No output devices for '%s': skipping device open/close test", audioDriver);
|
|
|
+ SDL_AudioQuit();
|
|
|
+ SDLTest_AssertPass("Call to SDL_AudioQuit()");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
/* Set spec */
|
|
|
SDL_memset(&desired, 0, sizeof(desired));
|
|
|
switch (j) {
|
|
@@ -217,7 +302,10 @@ int audio_initOpenCloseQuitAudio()
|
|
|
}
|
|
|
|
|
|
} /* spec loop */
|
|
|
- } /* driver loop */
|
|
|
+
|
|
|
+ audioDriver = NULL;
|
|
|
+
|
|
|
+ } /* driver loop */
|
|
|
|
|
|
/* Restart audio again */
|
|
|
_audioSetUp(NULL);
|
|
@@ -245,15 +333,33 @@ int audio_pauseUnpauseAudio()
|
|
|
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
|
|
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
|
|
|
|
|
|
- /* Loop over all available audio drivers */
|
|
|
- iMax = SDL_GetNumAudioDrivers();
|
|
|
- SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
|
|
|
- SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
|
|
|
+ /* Was a specific driver requested? */
|
|
|
+ audioDriver = SDL_GetHint(SDL_HINT_AUDIODRIVER);
|
|
|
+
|
|
|
+ if (audioDriver == NULL) {
|
|
|
+ /* Loop over all available audio drivers */
|
|
|
+ iMax = SDL_GetNumAudioDrivers();
|
|
|
+ SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
|
|
|
+ SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
|
|
|
+ } else {
|
|
|
+ /* A specific driver was requested for testing */
|
|
|
+ iMax = 1;
|
|
|
+ }
|
|
|
for (i = 0; i < iMax; i++) {
|
|
|
- audioDriver = SDL_GetAudioDriver(i);
|
|
|
- SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
|
|
- 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 (audioDriver == NULL) {
|
|
|
+ audioDriver = SDL_GetAudioDriver(i);
|
|
|
+ SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
|
|
+ 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 defined(__linux__)
|
|
|
+ if (DriverIsProblematic(audioDriver)) {
|
|
|
+ SDLTest_Log("Audio driver '%s' flagged as problematic: skipping pause/unpause test (set SDL_AUDIODRIVER=%s to force)", audioDriver, audioDriver);
|
|
|
+ audioDriver = NULL;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+#endif
|
|
|
+ }
|
|
|
|
|
|
if (hint && SDL_strcmp(audioDriver, hint) != 0) {
|
|
|
continue;
|
|
@@ -267,6 +373,16 @@ int audio_pauseUnpauseAudio()
|
|
|
SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
|
|
|
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
|
|
|
|
|
|
+ result = SDL_GetNumAudioDevices(SDL_FALSE);
|
|
|
+ SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(SDL_FALSE)");
|
|
|
+ SDLTest_AssertCheck(result >= 0, "Validate result value; expected: >=0 got: %d", result);
|
|
|
+ if (result <= 0) {
|
|
|
+ SDLTest_Log("No output devices for '%s': skipping pause/unpause test", audioDriver);
|
|
|
+ SDL_AudioQuit();
|
|
|
+ SDLTest_AssertPass("Call to SDL_AudioQuit()");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
/* Set spec */
|
|
|
SDL_memset(&desired, 0, sizeof(desired));
|
|
|
switch (j) {
|
|
@@ -341,7 +457,10 @@ int audio_pauseUnpauseAudio()
|
|
|
SDLTest_AssertPass("Call to SDL_AudioQuit()");
|
|
|
|
|
|
} /* spec loop */
|
|
|
- } /* driver loop */
|
|
|
+
|
|
|
+ audioDriver = NULL;
|
|
|
+
|
|
|
+ } /* driver loop */
|
|
|
|
|
|
/* Restart audio again */
|
|
|
_audioSetUp(NULL);
|