Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added testaudioinfo.c ...
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Oct 3, 2006
1 parent 897de3e commit aa918f9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 17 deletions.
5 changes: 4 additions & 1 deletion test/Makefile.in
Expand Up @@ -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)

Expand All @@ -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@

Expand Down
17 changes: 1 addition & 16 deletions test/loopwave.c
Expand Up @@ -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";
}
Expand Down Expand Up @@ -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);

Expand Down
50 changes: 50 additions & 0 deletions 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;
}

0 comments on commit aa918f9

Please sign in to comment.