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

Ulion ulion2002 at gmail.com
Wed Nov 7 16:21:10 CET 2007


2007/11/7, Ulion <ulion2002 at gmail.com>:
> 2007/11/7, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> > Hello,
> > On Wed, Nov 07, 2007 at 09:00:18PM +0800, Ulion wrote:
> > > 2007/11/7, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> > [...]
> > > > So removing the lock in the callback means that the signal can be
> > > > completely missed (due to the main thread being somewhere in the code
> > > > before or in-between pthread_cond_timedwait), so the worst-case
> > > > behaviour would be like just removing the callback completely, and
> > > > changes in the system scheduler could make that worst case quite likely.
> > > >
> > >
> > > OK, I got a no lock version of fix now, it also works fine without
> > > problems, please check it.
> >
> > If it ever doesn't print "reached timeout" your compiler is very stupid.
> > IOW this is completely broken and you could just remove the whole
> > callback stuff instead.
>
> I didn't figure what you mean. On my machine, the output is like this when init:
>
> AO: [macosx] setting stream format: 48000.0Hz 16bit
> [cac3][94][6144][1536][0][2] int BE S packed aligned
> AO: [macosx] actual format in use: 48000.0Hz 16bit
> [cac3][94][6144][1536][0][2] int BE S packed aligned
>
> and this when uninit:
> AO: [macosx] setting stream format: 44100.0Hz 16bit
> [lpcm][30][4][1][4][2] int BE S packed aligned
> AO: [macosx] actual format in use: 44100.0Hz 16bit
> [lpcm][30][4][1][4][2] int BE S packed aligned
>
> No timeout printed, please check my patch again.
>
>
> > This is exactly why writing lockless code comes after fully
> > understanding how to use locks correctly, fully understanding how the
> > CPU you work with works and realizing that it's pure luck if it works at
> > all without any asm code.
>
> asm code? I missed something?

I add 'volatile' declaration to the flag int, should this be safe?

-- 
Ulion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ao_osx_chg_fmt_dead_lock3.diff
Type: text/x-diff
Size: 3266 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20071107/8732367f/attachment.diff>


More information about the MPlayer-dev-eng mailing list