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

wm4 nfxjfg at googlemail.com
Wed Feb 19 12:16:43 CET 2014

On Wed, 19 Feb 2014 13:52:37 +0530
anshul <anshul.ffmpeg at gmail.com> wrote:

> I have done some doxygen kind of Documentation for function 
> av_cleanup_on_lib_unload()
> I have called ff_destroy_lock_avcodec inside av_cleanup_on_lib_unload, 
> since I am still looking for
> reference counting idea over there i would require function 
> ff_destroy_lock_avcodec.

Maybe I'm a bit too late to the party, but why would you want such a

This will lead to horrible stuff like library A trying to "unload"
libavcodec, while library B is still using it. You can't generally use
this function correctly.

And apparently all it does is silencing valgrind output.

You can have this easier and instruct valgrind to ignore it:

Besides, I think this lock manager stuff is horrible and shouldn't
exist at all. Instead, a statically initialized pthread lock should be
used. But this would require updating the w32pthread wrapper as well as
the OS/2 wrapper, which probably is not easy - but maybe worth it?

pthread_once is another pthread API function that could be used and
which might be easier to emulate than static mutex initializers.

More information about the ffmpeg-devel mailing list