From aa918f9ec6e064a410e8df6454abf26b2255f3c9 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 3 Oct 2006 20:05:33 +0000 Subject: [PATCH] Added testaudioinfo.c ... --- test/Makefile.in | 5 ++++- test/loopwave.c | 17 +-------------- test/testaudioinfo.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 test/testaudioinfo.c diff --git a/test/Makefile.in b/test/Makefile.in index cf4dc5375..ebc58cdb3 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -7,7 +7,7 @@ EXE = @EXE@ 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 @@ graywin$(EXE): $(srcdir)/graywin.c 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@ diff --git a/test/loopwave.c b/test/loopwave.c index 2965ce50f..d49572e25 100644 --- a/test/loopwave.c +++ b/test/loopwave.c @@ -69,26 +69,12 @@ main(int argc, char *argv[]) { 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 @@ main(int argc, char *argv[]) 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); diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c new file mode 100644 index 000000000..183a8c496 --- /dev/null +++ b/test/testaudioinfo.c @@ -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; +} +