# HG changeset patch # User Ryan C. Gordon # Date 1159905933 0 # Node ID e2f68b579a017801f2874918cff8b80cb8947ecf # Parent 7006b176ef4f884961419896d6d23bdcdaebdcac Added testaudioinfo.c ... diff -r 7006b176ef4f -r e2f68b579a01 test/Makefile.in --- 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@ diff -r 7006b176ef4f -r e2f68b579a01 test/loopwave.c --- 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); diff -r 7006b176ef4f -r e2f68b579a01 test/testaudioinfo.c --- /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; +} +