[FFmpeg-devel] [PATCH] avcodec/utils: use a default lock manager that uses a spinlock
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Fri Oct 18 08:41:36 CEST 2013
On 18.10.2013, at 01:47, Michael Niedermayer <michaelni at gmx.at> wrote:
>> 2. Use pthreads, and on Windows, one of the popular pthreads wrappers.
>
> Last time this idea came up someone said it doesnt work because
> theres no gurantee that the pthread mutex you then use is compatible
> with the threads its trying to sychronize which may be something
> else than pthread based. IIRC
To be honest, neither of these approaches work properly.
Your atomics approach will completely break (as in cause hangs) in an environment using cooperative scheduling if the user yields in a FFmpeg callback.
It also will burn the CPU for a whole time-slice in single-core environments if there is any congestion.
Note these also apply to the av_log changes.
Pthreads is not always available, and even if it is there is no guarantee it will be compatible with the threading system the application uses.
Or in short: we don't do it currently, because it simply doesn't work in general.
Whether we should support (either by default or with a simpler way that requires less code) a pthreads based application is a different question, but it's likely to break some use case, and probably needs to be considered and API change.
More information about the ffmpeg-devel
mailing list