From adb48411736a0f3e3e9294893c7e3e044e2e512f Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Mon, 4 Jun 2018 13:55:37 +0200 Subject: [PATCH] Remove explicit locking using av_lockmgr_register MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit av_lockmgr_register is deprecated and no-op since https://chromium.googlesource.com/chromium/third_party/ffmpeg/+/a04c2c707de2ce850f79870e84ac9d7ec7aa9143 Bug: webrtc:8745 Change-Id: I284c9a6edf88a584c3a5cb5dfae4ccf1be1f8851 Reviewed-on: https://webrtc-review.googlesource.com/39503 Commit-Queue: Mirko Bonadei Reviewed-by: Mirko Bonadei Reviewed-by: Henrik Boström Cr-Commit-Position: refs/heads/master@{#23508} --- .../codecs/h264/h264_decoder_impl.cc | 40 +++---------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/modules/video_coding/codecs/h264/h264_decoder_impl.cc index e0fa442f87..737194cadf 100644 --- a/modules/video_coding/codecs/h264/h264_decoder_impl.cc +++ b/modules/video_coding/codecs/h264/h264_decoder_impl.cc @@ -50,37 +50,9 @@ enum H264DecoderImplEvent { rtc::CriticalSection ffmpeg_init_lock; bool ffmpeg_initialized = false; -// Called by FFmpeg to do mutex operations if initialized using -// |InitializeFFmpeg|. Disabling thread safety analysis because void** does not -// play nicely with thread_annotations.h macros. -int LockManagerOperation(void** lock, - AVLockOp op) RTC_NO_THREAD_SAFETY_ANALYSIS { - switch (op) { - case AV_LOCK_CREATE: - *lock = new rtc::CriticalSection(); - return 0; - case AV_LOCK_OBTAIN: - static_cast(*lock)->Enter(); - return 0; - case AV_LOCK_RELEASE: - static_cast(*lock)->Leave(); - return 0; - case AV_LOCK_DESTROY: - delete static_cast(*lock); - *lock = nullptr; - return 0; - } - RTC_NOTREACHED() << "Unrecognized AVLockOp."; - return -1; -} - void InitializeFFmpeg() { rtc::CritScope cs(&ffmpeg_init_lock); if (!ffmpeg_initialized) { - if (av_lockmgr_register(LockManagerOperation) < 0) { - RTC_NOTREACHED() << "av_lockmgr_register failed."; - return; - } av_register_all(); ffmpeg_initialized = true; } @@ -200,12 +172,12 @@ int32_t H264DecoderImpl::InitDecode(const VideoCodec* codec_settings, return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } - // FFmpeg must have been initialized (with |av_lockmgr_register| and - // |av_register_all|) before we proceed. |InitializeFFmpeg| does this, which - // makes sense for WebRTC standalone. In other cases, such as Chromium, FFmpeg - // is initialized externally and calling |InitializeFFmpeg| would be - // thread-unsafe and result in FFmpeg being initialized twice, which could - // break other FFmpeg usage. See the |rtc_initialize_ffmpeg| flag. + // FFmpeg must have been initialized (with |av_register_all|) before we + // proceed. |InitializeFFmpeg| does this, which makes sense for WebRTC + // standalone. In other cases, such as Chromium, FFmpeg is initialized + // externally and calling |InitializeFFmpeg| would be thread-unsafe and result + // in FFmpeg being initialized twice, which could break other FFmpeg usage. + // See the |rtc_initialize_ffmpeg| flag. #if defined(WEBRTC_INITIALIZE_FFMPEG) // Make sure FFmpeg has been initialized. Subsequent |InitializeFFmpeg| calls // do nothing.