[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 13:29:14 CET 2007


Hello,
On Mon, Nov 05, 2007 at 07:59:25PM +0800, Ulion wrote:
> Hello,
> 
> I found a dead lock occur in ao_macosx (that part of code is from my
> patch based on vlc's source) when switch stream format for use digital
> passthrough output.
> The detail is, if the pthread_cond_timedwait timeouted, and detected
> the stream format already changed, or after 5 times
> pthread_cond_timedwait timeouted, when removing the stream listener,
> while on the other hand, the listener callback is blocked to wait the
> lock since it may be callbacked after pthread_cond_timedwait
> timeouted.
> Here's the fix, one thing to make the pthread_cond_timedwait wait
> longer, another thing to make the callback does not wait the lock,
> just siginal the wait cond. Now this code will not dead lock any more.
> 
> If  no objects, I will apply this soon in two days.

This should only be applied after the loads of other bugs and problems
have been fixed and then it is still necessary.
Firstly, if AudioStreamRemovePropertyListener fails the lock will not be
released and not destroyed.
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.
And btw. "timeouted" for all I know is not a word (and makes it hard for
me to read), "timed out" is. The same should apply to "callbacked", though
a simple "called" sounds better to me anyway.

Greetings,
Reimar Döffinger



More information about the MPlayer-dev-eng mailing list