[Libav-user] Using the libav* libraries in a thread-safe manner?
h.leppkes at gmail.com
Wed May 15 17:41:37 CEST 2013
On Wed, May 15, 2013 at 5:37 PM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> Joe Flowers <joe.flowers at ...> writes:
>> I need to use the libav* APIs (specifically the audio
>> codecs) in a thread-safe way, but they seem to be full
>> of malloc()s and free()s which aren't re-entrant.
> My malloc manual says that it uses mutexes "internally to
> protect the memory-management data structures employed by
> these functions" (alloc, free, etc.) to avoid corruption.
> Or do I miss something?
Using mutexes is not reentrant, however that has nothing to do with
malloc is thread-safe, but not reentrant.
That means you can use it just fine multi-threaded, however you could
deadlock if you somehow cancel a thread thats inside a malloc right
now (meaning the mutex is never unlocked)
Canceling threads like that should generally be avoided, and at least
the libav* libraries don't do it themself.
More information about the Libav-user