[MPlayer-dev-eng] [PATCH] Prevent ao_win32 from hanging during uninit(0)
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Thu Mar 5 13:27:39 CET 2009
On Thu, Mar 05, 2009 at 02:47:48AM -0500, David Bolen wrote:
> I suspect there may be flaws in how the buffered data is maintained
> that I'm still playing with. For example, based on a visual
> inspection, I can't see how write_waveOutBuffer can be correct, as it
> is written to permit chunks smaller than BUFFER_SIZE, but in such
> cases seems likely to reuse active buffers, not to mention the
> callback routine assumes always full buffers. The problem is I have a
> hard time figuring out how even if those items go wrong, it could lead
> to uninit() not eventually terminating. So maybe it's just a Windows
> thing (I'm currently operating on XP SP2).
The whole code is completely wrong: It uses a non-thread-safe buffer in
a multithreaded context.
More importantly,
> while(buffered_bytes > 0)usec_sleep(50000);
optimizes to
> if (buffered_bytes > 0) while(1) usec_sleep(50000);
which is an endless loop.
You'd have to look at the generated assembler to find out if that is
what causes your issue.
By declaring buffered_bytes as volatile this should be fixed, the
overall code still relies on luck for thread-safety though.
More information about the MPlayer-dev-eng
mailing list