[MPlayer-dev-eng] [PATCH] Fix dead lock in ao_macosx when switch stream format.

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Mon Nov 5 16:06:49 CET 2007


Hello,
On Mon, Nov 05, 2007 at 09:36:02PM +0800, Ulion wrote:
> 2007/11/5, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> > On Mon, Nov 05, 2007 at 07:59:25PM +0800, Ulion wrote:
> > Secondly, even after your change, the callback might use a condition
> > that has already been destroyed.
> > Which probably is the thing that causes the deadlock in the first place
> > (using a lock that has been destroyed), at least as I understand you
> > description.
> 
> You got wrong meaning, with gdb to check it on my a little slow
> powerpc system, the change stream and callback take a time longer than
> 0.5 second, but the format detection in the loop found the format
> already changed, it then to remove the listener, the remove call is
> waiting the listener callback return, but at mean time the listener is
> blocking and wait the mutex lock, so dead locked.

Then why not release the lock before calling the remove function?
And if that function waits for the callback that should be documented
and the lock and condition can be released immediately after, thus also
avoiding the missing destroy on error.

> So if we remove the wait mutex in the callback, here will be no
> deadlock, and after the listener return, the remove call wil finished,
> everything is ok.

I am not yet convinced this isn't a ugly hack instead of a proper fix.
I also think that such a solution means that a conditional is required
whereas my solution should allow using the more lightweight signals if
someone cares (I doubt it, this looks hardly performance-critical in any
way, and portability does not really matter either).

Greetings,
Reimar Döffinger



More information about the MPlayer-dev-eng mailing list