comparison test/loopwave.c @ 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 c121d94672cb
children 5c14978b1e97
comparison
equal deleted inserted replaced
3788:7006b176ef4f 3789:e2f68b579a01
67 int 67 int
68 main(int argc, char *argv[]) 68 main(int argc, char *argv[])
69 { 69 {
70 int i, n; 70 int i, n;
71 71
72 /* Print available audio drivers */
73 n = SDL_GetNumAudioDrivers();
74 if (n == 0) {
75 printf("No built-in audio drivers\n");
76 } else {
77 printf("Built-in audio drivers:");
78 for (i = 0; i < n; ++i) {
79 if (i > 0) {
80 printf(",");
81 }
82 printf(" %s", SDL_GetAudioDriver(i));
83 }
84 printf("\n");
85 }
86
87 /* Load the SDL library */ 72 /* Load the SDL library */
88 if (SDL_Init(SDL_INIT_AUDIO) < 0) { 73 if (SDL_Init(SDL_INIT_AUDIO) < 0) {
89 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); 74 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
90 return (1); 75 return (1);
91 } 76 }
77
92 if (argv[1] == NULL) { 78 if (argv[1] == NULL) {
93 argv[1] = "sample.wav"; 79 argv[1] = "sample.wav";
94 } 80 }
95 /* Load the wave file into memory */ 81 /* Load the wave file into memory */
96 if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) { 82 if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
118 quit(2); 104 quit(2);
119 } 105 }
120 SDL_PauseAudio(0); 106 SDL_PauseAudio(0);
121 107
122 /* Let the audio run */ 108 /* Let the audio run */
123 printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
124 while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) 109 while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING))
125 SDL_Delay(1000); 110 SDL_Delay(1000);
126 111
127 /* Clean up on signal */ 112 /* Clean up on signal */
128 SDL_CloseAudio(); 113 SDL_CloseAudio();