Added testaudioinfo.c ... SDL-ryan-multiple-audio-device
authorRyan C. Gordon
Tue, 03 Oct 2006 20:05:33 +0000
branchSDL-ryan-multiple-audio-device
changeset 3789e2f68b579a01
parent 3788 7006b176ef4f
child 3790 8f8209f8da6d
Added testaudioinfo.c ...
test/Makefile.in
test/loopwave.c
test/testaudioinfo.c
     1.1 --- a/test/Makefile.in	Tue Oct 03 18:32:34 2006 +0000
     1.2 +++ b/test/Makefile.in	Tue Oct 03 20:05:33 2006 +0000
     1.3 @@ -7,7 +7,7 @@
     1.4  CFLAGS  = @CFLAGS@
     1.5  LIBS	= @LIBS@
     1.6  
     1.7 -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)
     1.8 +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)
     1.9  
    1.10  all: Makefile $(TARGETS)
    1.11  
    1.12 @@ -23,6 +23,9 @@
    1.13  loopwave$(EXE): $(srcdir)/loopwave.c
    1.14  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    1.15  
    1.16 +testaudioinfo$(EXE): $(srcdir)/testaudioinfo.c
    1.17 +	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
    1.18 +
    1.19  testalpha$(EXE): $(srcdir)/testalpha.c
    1.20  	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
    1.21  
     2.1 --- a/test/loopwave.c	Tue Oct 03 18:32:34 2006 +0000
     2.2 +++ b/test/loopwave.c	Tue Oct 03 20:05:33 2006 +0000
     2.3 @@ -69,26 +69,12 @@
     2.4  {
     2.5      int i, n;
     2.6  
     2.7 -    /* Print available audio drivers */
     2.8 -    n = SDL_GetNumAudioDrivers();
     2.9 -    if (n == 0) {
    2.10 -        printf("No built-in audio drivers\n");
    2.11 -    } else {
    2.12 -        printf("Built-in audio drivers:");
    2.13 -        for (i = 0; i < n; ++i) {
    2.14 -            if (i > 0) {
    2.15 -                printf(",");
    2.16 -            }
    2.17 -            printf(" %s", SDL_GetAudioDriver(i));
    2.18 -        }
    2.19 -        printf("\n");
    2.20 -    }
    2.21 -
    2.22      /* Load the SDL library */
    2.23      if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    2.24          fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    2.25          return (1);
    2.26      }
    2.27 +
    2.28      if (argv[1] == NULL) {
    2.29          argv[1] = "sample.wav";
    2.30      }
    2.31 @@ -120,7 +106,6 @@
    2.32      SDL_PauseAudio(0);
    2.33  
    2.34      /* Let the audio run */
    2.35 -    printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
    2.36      while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING))
    2.37          SDL_Delay(1000);
    2.38  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/testaudioinfo.c	Tue Oct 03 20:05:33 2006 +0000
     3.3 @@ -0,0 +1,50 @@
     3.4 +#include "SDL.h"
     3.5 +
     3.6 +static void print_devices(int iscapture)
     3.7 +{
     3.8 +    const char *typestr = ((iscapture) ? "capture" : "output");
     3.9 +    int n = SDL_GetNumAudioDevices(iscapture);
    3.10 +
    3.11 +    if (n == 0)
    3.12 +        printf("No %s devices.\n\n", typestr);
    3.13 +    else
    3.14 +    {
    3.15 +        int i;
    3.16 +        printf("%s devices:\n", typestr);
    3.17 +        for (i = 0; i < n; i++) {
    3.18 +            printf("  %s\n", SDL_GetAudioDevice(i, iscapture));
    3.19 +        }
    3.20 +        printf("\n");
    3.21 +    }
    3.22 +}
    3.23 +
    3.24 +int main(int argc, char **argv)
    3.25 +{
    3.26 +    /* Print available audio drivers */
    3.27 +    int n = SDL_GetNumAudioDrivers();
    3.28 +    if (n == 0) {
    3.29 +        printf("No built-in audio drivers\n\n");
    3.30 +    } else {
    3.31 +        printf("Built-in audio drivers:\n");
    3.32 +        int i;
    3.33 +        for (i = 0; i < n; ++i) {
    3.34 +            printf("  %s\n", SDL_GetAudioDriver(i));
    3.35 +        }
    3.36 +        printf("\n");
    3.37 +    }
    3.38 +
    3.39 +    /* Load the SDL library */
    3.40 +    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    3.41 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    3.42 +        return (1);
    3.43 +    }
    3.44 +
    3.45 +    printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    3.46 +
    3.47 +    print_devices(0);
    3.48 +    print_devices(1);
    3.49 +
    3.50 +    SDL_Quit();
    3.51 +    return 0;
    3.52 +}
    3.53 +