Skip to content

Commit

Permalink
avcodec/utils: use atomic operations on entangled_thread_counter
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Mar 13, 2015
1 parent b910c6c commit b14de8e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libavcodec/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3610,8 +3610,8 @@ int ff_lock_avcodec(AVCodecContext *log_ctx, AVCodec *codec)
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
return -1;
}
entangled_thread_counter++;
if (entangled_thread_counter != 1 &&

if (avpriv_atomic_int_add_and_fetch(&entangled_thread_counter, 1) != 1 &&
!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE)) {
av_log(log_ctx, AV_LOG_ERROR,
"Insufficient thread locking. At least %d threads are "
Expand All @@ -3632,7 +3632,7 @@ int ff_unlock_avcodec(void)
{
av_assert0(ff_avcodec_locked);
ff_avcodec_locked = 0;
entangled_thread_counter--;
avpriv_atomic_int_add_and_fetch(&entangled_thread_counter, -1);
if (lockmgr_cb) {
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
return -1;
Expand Down

0 comments on commit b14de8e

Please sign in to comment.