[Libav-user] Using the libav* libraries in a thread-safe manner?

Alex Cohn alexcohn at netvision.net.il
Wed May 15 18:26:05 CEST 2013

On 15 May 2013 19:13, "Joe Flowers" <joe.flowers at nofreewill.com> wrote:
> Carl and Hendrik,
> Thank you very much for your comments and expertise.
> You are right, I'm mixing up thread-safety and re-entrantcy.  Sorry.
> With Hendrik's advice on not cancelling threads to prevent a deadlock or
zombie-type threads, I'm now more concerned with thread-safeness.
> 1.
> I know when I configure and make FFMPEG, there is an "--enable-pthreads"
option. If I am understanding things correctly, this particular option is
not relevant to the thread safety of a C program calling the libav* APIs,

Some codecs allow multithreaded processing to speed things up (on multicore
systems). That's where pthreads become relevant.

> 2.
> I am using gcc on Ubuntu to compile and link to the libav* libraries and
am wondering if I need to use a particular "-pthreads" option (or something
else) with gcc to make sure I am using thread-safe C libraries to get a
thread-safe malloc()?

In your toolchain, malloc is thread-safe.

>   The reason I ask is because in Windoze one has to link with the
mulithreaded C libraries (*MT.lib) to get a thread-safe version of malloc().

Non-multithread RT libraries for Microsoft C compiler are long gone.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130515/49a0a510/attachment.html>

More information about the Libav-user mailing list