Mercurial > SDL_sound_CoreAudio
comparison playsound/test_sdlsound.c @ 13:f2af6266775f
Minor fixes.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 18 Sep 2001 11:01:11 +0000 |
parents | 341cea3e13c6 |
children | 4acb5260d684 |
comparison
equal
deleted
inserted
replaced
12:2888101dcf98 | 13:f2af6266775f |
---|---|
63 static void output_decoders(void) | 63 static void output_decoders(void) |
64 { | 64 { |
65 const Sound_DecoderInfo **rc = Sound_AvailableDecoders(); | 65 const Sound_DecoderInfo **rc = Sound_AvailableDecoders(); |
66 const Sound_DecoderInfo **i; | 66 const Sound_DecoderInfo **i; |
67 | 67 |
68 printf("Supported fileformats:\n"); | 68 printf("Supported sound formats:\n"); |
69 if (*rc == NULL) | 69 if (*rc == NULL) |
70 printf(" * Apparently, NONE!\n"); | 70 printf(" * Apparently, NONE!\n"); |
71 else | 71 else |
72 { | 72 { |
73 for (i = rc; *i != NULL; i++) | 73 for (i = rc; *i != NULL; i++) |
88 { | 88 { |
89 Sound_Sample *sample = (Sound_Sample *) userdata; | 89 Sound_Sample *sample = (Sound_Sample *) userdata; |
90 Uint32 rc = Sound_Decode(sample); | 90 Uint32 rc = Sound_Decode(sample); |
91 | 91 |
92 if (sample->flags & SOUND_SAMPLEFLAG_EOF) | 92 if (sample->flags & SOUND_SAMPLEFLAG_EOF) |
93 { | |
94 printf("EOF condition in decoding! (this is okay.)\n"); | |
95 done_flag = 1; | 93 done_flag = 1; |
96 } /* if */ | |
97 | 94 |
98 else if (sample->flags & SOUND_SAMPLEFLAG_ERROR) | 95 else if (sample->flags & SOUND_SAMPLEFLAG_ERROR) |
99 { | 96 { |
100 printf("Error condition in decoding! (this is bad.)\n"); | 97 printf("Error condition in decoding!\n"); |
101 done_flag = 1; | 98 done_flag = 1; |
102 } /* else if */ | 99 } /* else if */ |
103 | 100 |
104 assert(rc <= len); | 101 assert(rc <= len); |
105 | 102 |
160 sdl_desired.channels = 2; | 157 sdl_desired.channels = 2; |
161 sdl_desired.samples = 4096; | 158 sdl_desired.samples = 4096; |
162 sdl_desired.callback = test_callback; | 159 sdl_desired.callback = test_callback; |
163 sdl_desired.userdata = sample; | 160 sdl_desired.userdata = sample; |
164 | 161 |
162 #if 1 | |
165 if ( SDL_OpenAudio(&sdl_desired, NULL) < 0 ) | 163 if ( SDL_OpenAudio(&sdl_desired, NULL) < 0 ) |
166 { | 164 { |
167 printf("SDL_OpenAudio() failed!\n" | 165 printf("SDL_OpenAudio() failed!\n" |
168 " reason: [%s].\n", SDL_GetError()); | 166 " reason: [%s].\n", SDL_GetError()); |
169 Sound_Quit(); | 167 Sound_Quit(); |
170 SDL_Quit(); | 168 SDL_Quit(); |
171 return(42); | 169 return(42); |
172 } /* if */ | 170 } /* if */ |
173 | 171 |
174 SDL_PauseAudio(0); | 172 SDL_PauseAudio(0); |
175 | |
176 while (!done_flag) | 173 while (!done_flag) |
177 SDL_Delay(10); | 174 SDL_Delay(10); |
175 SDL_PauseAudio(1); | |
176 | |
177 /* | |
178 * This just decodes the file, and dumps the decoded waveform to | |
179 * stderr. Use with caution. | |
180 */ | |
181 #else | |
182 { | |
183 Uint32 rc; | |
184 while ((rc = Sound_Decode(sample)) == sample->buffer_size) | |
185 fwrite(sample->buffer, rc, 1, stderr); | |
186 } | |
187 #endif | |
188 | |
178 | 189 |
179 Sound_FreeSample(sample); | 190 Sound_FreeSample(sample); |
180 | 191 |
181 Sound_Quit(); | 192 Sound_Quit(); |
182 SDL_Quit(); | 193 SDL_Quit(); |