Mercurial > SDL_sound_CoreAudio
comparison playsound/playsound.c @ 214:e27b33a6d5fe
Now attempts to wait for SDL to finish playing the end of the buffered
data before closing the audio device.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sun, 13 Jan 2002 19:50:02 +0000 |
parents | 9d436dbb1666 |
children | d6b24586822a |
comparison
equal
deleted
inserted
replaced
213:948b62500a54 | 214:e27b33a6d5fe |
---|---|
238 SDL_AudioSpec sdl_actual; | 238 SDL_AudioSpec sdl_actual; |
239 Sound_Sample *sample; | 239 Sound_Sample *sample; |
240 int predecode = 0; | 240 int predecode = 0; |
241 int use_specific_audiofmt = 0; | 241 int use_specific_audiofmt = 0; |
242 int i; | 242 int i; |
243 int delay; | |
243 | 244 |
244 setbuf(stdout, NULL); | 245 setbuf(stdout, NULL); |
245 setbuf(stderr, NULL); | 246 setbuf(stderr, NULL); |
246 | 247 |
247 /* !!! FIXME: Move this to a parse_cmdline() function... */ | 248 /* !!! FIXME: Move this to a parse_cmdline() function... */ |
461 { | 462 { |
462 SDL_Delay(10); | 463 SDL_Delay(10); |
463 } /* while */ | 464 } /* while */ |
464 SDL_PauseAudio(1); | 465 SDL_PauseAudio(1); |
465 | 466 |
467 /* Sleep two buffers' worth of audio before closing, in order | |
468 to allow the playback to finish. This isn't always enough; | |
469 perhaps SDL needs a way to explicitly wait for device drain? */ | |
470 delay = 2 * 1000 * sdl_desired.samples / sdl_desired.freq; | |
471 SDL_Delay(delay); | |
472 | |
466 if (sample->flags & SOUND_SAMPLEFLAG_ERROR) | 473 if (sample->flags & SOUND_SAMPLEFLAG_ERROR) |
467 { | 474 { |
468 fprintf(stderr, "Error in decoding sound file!\n" | 475 fprintf(stderr, "Error in decoding sound file!\n" |
469 " reason: [%s].\n", Sound_GetError()); | 476 " reason: [%s].\n", Sound_GetError()); |
470 } /* if */ | 477 } /* if */ |