comparison playsound/playsound.c @ 168:87b00f023710

Added --predecode functionality.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 26 Nov 2001 04:33:50 +0000
parents 033afe96afbc
children 69922f6a5c74
comparison
equal deleted inserted replaced
167:82acaa7107c2 168:87b00f023710
164 " --rate x Playback at sample rate of x HZ.\n" 164 " --rate x Playback at sample rate of x HZ.\n"
165 " --format fmt Playback in fmt format (see below).\n" 165 " --format fmt Playback in fmt format (see below).\n"
166 " --channels n Playback on n channels (1 or 2).\n" 166 " --channels n Playback on n channels (1 or 2).\n"
167 " --version Display version information and exit.\n" 167 " --version Display version information and exit.\n"
168 " --decoders List supported sound formats and exit.\n" 168 " --decoders List supported sound formats and exit.\n"
169 " --predecode Decode entire sample before playback.\n"
169 " --help Display this information and exit.\n" 170 " --help Display this information and exit.\n"
170 "\n" 171 "\n"
171 " Valid arguments to the --format option are:\n" 172 " Valid arguments to the --format option are:\n"
172 " U8 Unsigned 8-bit.\n" 173 " U8 Unsigned 8-bit.\n"
173 " S8 Signed 8-bit.\n" 174 " S8 Signed 8-bit.\n"
202 { 203 {
203 Sound_AudioInfo sound_desired; 204 Sound_AudioInfo sound_desired;
204 SDL_AudioSpec sdl_desired; 205 SDL_AudioSpec sdl_desired;
205 SDL_AudioSpec sdl_actual; 206 SDL_AudioSpec sdl_actual;
206 Sound_Sample *sample; 207 Sound_Sample *sample;
208 int predecode = 0;
207 int use_specific_audiofmt = 0; 209 int use_specific_audiofmt = 0;
208 int i; 210 int i;
211
212 setbuf(stdout, NULL);
213 setbuf(stderr, NULL);
209 214
210 /* !!! FIXME: Move this to a parse_cmdline() function... */ 215 /* !!! FIXME: Move this to a parse_cmdline() function... */
211 if (argc < 2) 216 if (argc < 2)
212 { 217 {
213 output_usage(argv[0]); 218 output_usage(argv[0]);
280 } /* if */ 285 } /* if */
281 286
282 output_decoders(); 287 output_decoders();
283 Sound_Quit(); 288 Sound_Quit();
284 return(0); 289 return(0);
290 } /* else if */
291
292 else if (strcmp(argv[i], "--predecode") == 0)
293 {
294 predecode = 1;
285 } /* else if */ 295 } /* else if */
286 296
287 else 297 else
288 { 298 {
289 fprintf(stderr, "unknown option: \"%s\"\n", argv[i]); 299 fprintf(stderr, "unknown option: \"%s\"\n", argv[i]);
373 return(42); 383 return(42);
374 } /* if */ 384 } /* if */
375 385
376 printf("Now playing [%s]...\n", argv[i]); 386 printf("Now playing [%s]...\n", argv[i]);
377 387
388 if (predecode)
389 {
390 printf(" predecoding...", argv[i]);
391 decoded_bytes = Sound_DecodeAll(sample);
392 decoded_ptr = sample->buffer;
393 if (sample->flags & SOUND_SAMPLEFLAG_ERROR)
394 {
395 fprintf(stderr,
396 "Couldn't fully decode \"%s\"!\n"
397 " reason: [%s].\n",
398 " (playing first %lu bytes of decoded data...)\n",
399 argv[i], Sound_GetError(), decoded_bytes);
400 } /* if */
401 else
402 {
403 printf("done.\n");
404 } /* else */
405 } /* if */
406
378 done_flag = 0; 407 done_flag = 0;
379 SDL_PauseAudio(0); 408 SDL_PauseAudio(0);
380 while (!done_flag) 409 while (!done_flag)
381 { 410 {
382 SDL_Delay(10); 411 SDL_Delay(10);