# HG changeset patch # User Ryan C. Gordon # Date 1010951402 0 # Node ID e27b33a6d5fe5315d0987b4d2e918980caef612f # Parent 948b62500a548061e52b9355c493ac77535bf05b Now attempts to wait for SDL to finish playing the end of the buffered data before closing the audio device. diff -r 948b62500a54 -r e27b33a6d5fe playsound/playsound.c --- a/playsound/playsound.c Sun Jan 13 19:48:16 2002 +0000 +++ b/playsound/playsound.c Sun Jan 13 19:50:02 2002 +0000 @@ -240,6 +240,7 @@ int predecode = 0; int use_specific_audiofmt = 0; int i; + int delay; setbuf(stdout, NULL); setbuf(stderr, NULL); @@ -463,6 +464,12 @@ } /* while */ SDL_PauseAudio(1); + /* Sleep two buffers' worth of audio before closing, in order + to allow the playback to finish. This isn't always enough; + perhaps SDL needs a way to explicitly wait for device drain? */ + delay = 2 * 1000 * sdl_desired.samples / sdl_desired.freq; + SDL_Delay(delay); + if (sample->flags & SOUND_SAMPLEFLAG_ERROR) { fprintf(stderr, "Error in decoding sound file!\n"