[FFmpeg-devel] [PATCH v3 2/3] libavcodec/utils.c: simplify avcodec locking with atomics

James Almer jamrial at gmail.com
Sat Nov 25 20:15:19 EET 2017


On 11/25/2017 3:07 PM, Clément Bœsch wrote:
> On Sat, Nov 25, 2017 at 05:01:56PM +0000, Rostislav Pehlivanov wrote:
> [...]
>> -volatile int ff_avcodec_locked;
>> +static atomic_bool ff_avcodec_locked;
>>  static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
>>  static void *codec_mutex;
>>  static void *avformat_mutex;
>> @@ -1937,6 +1937,7 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
>>  
>>  int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
>>  {
> 
>> +    _Bool exp = 1;
> 
> why _Bool instead of atomic_bool?

See http://en.cppreference.com/w/c/atomic/atomic_compare_exchange

The variable passed as argument for *expected needs to be of the
non-atomic type of the variable passed for *obj.


More information about the ffmpeg-devel mailing list