[FFmpeg-devel] [PATCH] avcodec thread safety fix

Daniel Steinberg daniel
Tue May 12 22:36:19 CEST 2009

Although avcodec_open/avcodec_close are known to have thread-safety
issues (hence the entangled_thread_counter), it is not sufficient in a
multi-threaded environment to simply protect calls to them with a
mutex, because av_find_stream_info() internally calls them as well.
Further, av_find_stream_info() may subsequently block for input, so it
is not a good idea to hold a mutex for the duration of its call.

Attached is a proposed fix that allows clients to specify a locking
routine that, if non-NULL, will be called by avcodec_open() and
avcodec_close(), thereby protecting them from re-entrancy regardless
of the calling source.

Daniel Steinberg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avcodec.patch
Type: application/octet-stream
Size: 2447 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090512/369a869c/attachment.obj>

More information about the ffmpeg-devel mailing list