changeset 3789:e2f68b579a01 SDL-ryan-multiple-audio-device

Added testaudioinfo.c ...
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 03 Oct 2006 20:05:33 +0000
parents 7006b176ef4f
children 8f8209f8da6d
files test/Makefile.in test/loopwave.c test/testaudioinfo.c
diffstat 3 files changed, 55 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/test/Makefile.in	Tue Oct 03 18:32:34 2006 +0000
+++ b/test/Makefile.in	Tue Oct 03 20:05:33 2006 +0000
@@ -7,7 +7,7 @@
 CFLAGS  = @CFLAGS@
 LIBS	= @LIBS@
 
-TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testalpha$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcdrom$(EXE) testcursor$(EXE) testdyngl$(EXE) testerror$(EXE) testfile$(EXE) testgamma$(EXE) testgl$(EXE) testgl2$(EXE) testhread$(EXE) testiconv$(EXE) testjoystick$(EXE) testkeys$(EXE) testlock$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testsem$(EXE) testsprite$(EXE) testsprite2$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm$(EXE) testwm2$(EXE) threadwin$(EXE) torturethread$(EXE)
+TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testaudioinfo$(EXE) testalpha$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcdrom$(EXE) testcursor$(EXE) testdyngl$(EXE) testerror$(EXE) testfile$(EXE) testgamma$(EXE) testgl$(EXE) testgl2$(EXE) testhread$(EXE) testiconv$(EXE) testjoystick$(EXE) testkeys$(EXE) testlock$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testsem$(EXE) testsprite$(EXE) testsprite2$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm$(EXE) testwm2$(EXE) threadwin$(EXE) torturethread$(EXE)
 
 all: Makefile $(TARGETS)
 
@@ -23,6 +23,9 @@
 loopwave$(EXE): $(srcdir)/loopwave.c
 	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
 
+testaudioinfo$(EXE): $(srcdir)/testaudioinfo.c
+	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
+
 testalpha$(EXE): $(srcdir)/testalpha.c
 	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
 
--- a/test/loopwave.c	Tue Oct 03 18:32:34 2006 +0000
+++ b/test/loopwave.c	Tue Oct 03 20:05:33 2006 +0000
@@ -69,26 +69,12 @@
 {
     int i, n;
 
-    /* Print available audio drivers */
-    n = SDL_GetNumAudioDrivers();
-    if (n == 0) {
-        printf("No built-in audio drivers\n");
-    } else {
-        printf("Built-in audio drivers:");
-        for (i = 0; i < n; ++i) {
-            if (i > 0) {
-                printf(",");
-            }
-            printf(" %s", SDL_GetAudioDriver(i));
-        }
-        printf("\n");
-    }
-
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
         fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
+
     if (argv[1] == NULL) {
         argv[1] = "sample.wav";
     }
@@ -120,7 +106,6 @@
     SDL_PauseAudio(0);
 
     /* Let the audio run */
-    printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
     while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING))
         SDL_Delay(1000);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testaudioinfo.c	Tue Oct 03 20:05:33 2006 +0000
@@ -0,0 +1,50 @@
+#include "SDL.h"
+
+static void print_devices(int iscapture)
+{
+    const char *typestr = ((iscapture) ? "capture" : "output");
+    int n = SDL_GetNumAudioDevices(iscapture);
+
+    if (n == 0)
+        printf("No %s devices.\n\n", typestr);
+    else
+    {
+        int i;
+        printf("%s devices:\n", typestr);
+        for (i = 0; i < n; i++) {
+            printf("  %s\n", SDL_GetAudioDevice(i, iscapture));
+        }
+        printf("\n");
+    }
+}
+
+int main(int argc, char **argv)
+{
+    /* Print available audio drivers */
+    int n = SDL_GetNumAudioDrivers();
+    if (n == 0) {
+        printf("No built-in audio drivers\n\n");
+    } else {
+        printf("Built-in audio drivers:\n");
+        int i;
+        for (i = 0; i < n; ++i) {
+            printf("  %s\n", SDL_GetAudioDriver(i));
+        }
+        printf("\n");
+    }
+
+    /* Load the SDL library */
+    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
+        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        return (1);
+    }
+
+    printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
+
+    print_devices(0);
+    print_devices(1);
+
+    SDL_Quit();
+    return 0;
+}
+