Commit 1ea1a90edb23266b606984596506f826ade66a2d

Ethan Lee 2022-09-29T10:41:40

testaudioinfo: Also test SDL_GetAudioDeviceSpec

diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c
index 6f1e0c7..340aac6 100644
--- a/test/testaudioinfo.c
+++ b/test/testaudioinfo.c
@@ -15,6 +15,7 @@
 static void
 print_devices(int iscapture)
 {
+    SDL_AudioSpec spec;
     const char *typestr = ((iscapture) ? "capture" : "output");
     int n = SDL_GetNumAudioDevices(iscapture);
 
@@ -32,6 +33,12 @@ print_devices(int iscapture)
                 SDL_Log("  %d: %s\n", i, name);
             else
                 SDL_Log("  %d Error: %s\n", i, SDL_GetError());
+
+            if (SDL_GetAudioDeviceSpec(i, iscapture, &spec) == 0) {
+                SDL_Log("     Sample Rate: %d\n", spec.freq);
+                SDL_Log("     Channels: %d\n", spec.channels);
+                SDL_Log("     SDL_AudioFormat: %X\n", spec.format);
+            }
         }
         SDL_Log("\n");
     }
@@ -76,9 +83,9 @@ main(int argc, char **argv)
     } else {
         SDL_Log("Default Output Name: %s\n", deviceName != NULL ? deviceName : "unknown");
         SDL_free(deviceName);
-        SDL_Log("Sampling Rate: %d\n", spec.freq);
-        SDL_Log("Number of Channels: %d\n", spec.channels);
-        SDL_Log("Audio Format: %d\n", spec.format);
+        SDL_Log("Sample Rate: %d\n", spec.freq);
+        SDL_Log("Channels: %d\n", spec.channels);
+        SDL_Log("SDL_AudioFormat: %X\n", spec.format);
     }
 
     if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 1) < 0) {
@@ -86,9 +93,9 @@ main(int argc, char **argv)
     } else {
         SDL_Log("Default Capture Name: %s\n", deviceName != NULL ? deviceName : "unknown");
         SDL_free(deviceName);
-        SDL_Log("Sampling Rate: %d\n", spec.freq);
-        SDL_Log("Number of Channels: %d\n", spec.channels);
-        SDL_Log("Audio Format: %d\n", spec.format);
+        SDL_Log("Sample Rate: %d\n", spec.freq);
+        SDL_Log("Channels: %d\n", spec.channels);
+        SDL_Log("SDL_AudioFormat: %X\n", spec.format);
     }