[MPlayer-dev-eng] [PATCH] Prevent ao_win32 from hanging during uninit(0)
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Mon Mar 9 20:17:03 CET 2009
On Mon, Mar 09, 2009 at 02:54:17PM -0400, David Bolen wrote:
> @@ -251,8 +251,17 @@
> // close audio device
> static void uninit(int immed)
> {
> - if(!immed)while(buffered_bytes > 0)usec_sleep(50000);
> - else buffered_bytes=0;
> + if (!immed) {
> + /* Limit wait by pending data. +2 = round up + room for callbacks */
> + int wait_cnt = (get_delay() * 20) + 2;
> + while (wait_cnt-- && buffered_bytes > 0) usec_sleep(50000);
> + } else buffered_bytes = 0;
> +
> + if (buffered_bytes > 0) {
> + mp_msg(MSGT_AO, MSGL_WARN,
> + "Warning: Failed to play %d buffered bytes\n", buffered_bytes);
> + buffered_bytes = 0;
> + }
> waveOutReset(hWaveOut);
> waveOutClose(hWaveOut);
Latest SVN uses different code.
Anyway reading the documentation gives a proper solution (waiting for
waveOutClose to succeed).
Implemented in SVN, but tested only compilation.
And ao_data.buffersize for some reason is supposed to represent the delay
caused by buffers in the OS/soundcard/etc.
More information about the MPlayer-dev-eng
mailing list