[MPlayer-dev-eng] [PATCH] Fix dead lock in ao_macosx when switch stream format.
Ulion
ulion2002 at gmail.com
Wed Nov 7 16:09:22 CET 2007
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?
> If it still worse that sure raises the question wtf all that code is
> supposed to be good for if it works with over half of it disabled.
>
Half of it disabled? You mean remove callback? Remove callback will
make the change format at least last for 0.5 seconds, with the
callback we will finish the change as soon as possible. I think you
mis-understood this patch, please check it again.
--
Ulion
More information about the MPlayer-dev-eng
mailing list