[FFmpeg-devel] default lock mechanism in libavcodec/utils.c

wm4 nfxjfg at googlemail.com
Thu Feb 20 09:31:14 CET 2014


On Thu, 20 Feb 2014 13:27:28 +0530
anshul <anshul.ffmpeg at gmail.com> wrote:

> There was an another idea of michael that using reference count,
> Reimar Döffinger if you want reference count then you can help me over 
> there by some guideline, I have not implemented that idea because if i 
> miss an reference count then that bug would take more time
> to solve.

Reference counting? This is just awful. How are you going to
synchronize initialization and reference counting if you have no lock
that you could use?

Let me repeat: global library initialization functions are broken by
design, and global library uninitialization functions are even more
broken. If a library has static data that must be initialized once, it
should use pthread_once() to synchronize this initialization.

(Does this bizarre lock manager stuff even synchronize initialization?
I think it does after recent changes, but it's still a very bad
emulation of pthread_once().)

By the way, it seems this function can be used to implement
pthread_once on windows:

http://msdn.microsoft.com/en-us/library/ms683493(v=vs.85).aspx

But it seems it's not supported on XP, and I'm not sure how to do it on
OS/2.

> 
> just now i am following below idea:
> 
> some code that gets called on exit or
> lib unloading by the OS.

Using atexit()? Might work...


More information about the ffmpeg-devel mailing list