summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2017-12-11 20:59:56 +0100
committerHendrik Leppkes <h.leppkes@gmail.com>2017-12-11 21:16:06 +0100
commitfd542b6f2026f1aa163882ee0283958598a97c31 (patch)
tree560bfe34a23731098015cb890a1919a58aa4df18 /libavcodec
parentc7a5e80f569d312c9d2f0dc534e07630eecd5a34 (diff)
downloadffmpeg-streaming-fd542b6f2026f1aa163882ee0283958598a97c31.zip
ffmpeg-streaming-fd542b6f2026f1aa163882ee0283958598a97c31.tar.gz
Revert "libavcodec/utils.c: simplify avcodec locking with atomics"
This reverts commit 590136e78da3d091ea99ab5432543d47a559a461. Atomics are not required for this variable, because it is protected through the lock manager, and the use of atomics here is not compatible with the c11 emulation wrappersi. Fixes FATE on MSVC, among other setups which use the compat wrappers.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/internal.h1
-rw-r--r--libavcodec/utils.c12
2 files changed, 7 insertions, 6 deletions
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 6deaf1d..30cb9a0 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -241,6 +241,7 @@ int ff_init_buffer_info(AVCodecContext *s, AVFrame *frame);
void ff_color_frame(AVFrame *frame, const int color[4]);
+extern volatile int ff_avcodec_locked;
int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec);
int ff_unlock_avcodec(const AVCodec *codec);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index baf0911..873f39f 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -115,7 +115,7 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = NULL;
#endif
-static atomic_bool ff_avcodec_locked;
+volatile int ff_avcodec_locked;
static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
static void *codec_mutex;
static void *avformat_mutex;
@@ -1943,7 +1943,6 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
{
- _Bool exp = 0;
if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
return 0;
@@ -1959,21 +1958,22 @@ int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
atomic_load(&entangled_thread_counter));
if (!lockmgr_cb)
av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please see av_lockmgr_register()\n");
- atomic_store(&ff_avcodec_locked, 1);
+ ff_avcodec_locked = 1;
ff_unlock_avcodec(codec);
return AVERROR(EINVAL);
}
- av_assert0(atomic_compare_exchange_strong(&ff_avcodec_locked, &exp, 1));
+ av_assert0(!ff_avcodec_locked);
+ ff_avcodec_locked = 1;
return 0;
}
int ff_unlock_avcodec(const AVCodec *codec)
{
- _Bool exp = 1;
if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
return 0;
- av_assert0(atomic_compare_exchange_strong(&ff_avcodec_locked, &exp, 0));
+ av_assert0(ff_avcodec_locked);
+ ff_avcodec_locked = 0;
atomic_fetch_add(&entangled_thread_counter, -1);
if (lockmgr_cb) {
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
OpenPOWER on IntegriCloud