From 265931ea3ca8700264e66aa9c43f8723578e6859 Mon Sep 17 00:00:00 2001 From: Markus Handell Date: Fri, 10 Jul 2020 12:23:48 +0200 Subject: [PATCH] Migrate VideoStreamDecoderImpl to webrtc::Mutex. Bug: webrtc:11567 Change-Id: Ie5ae7aa630f1c702634cf6663853114b4e0f9d9b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179064 Reviewed-by: Magnus Flodman Commit-Queue: Markus Handell Cr-Commit-Position: refs/heads/master@{#31698} --- video/BUILD.gn | 1 + video/video_stream_decoder_impl.cc | 4 ++-- video/video_stream_decoder_impl.h | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/video/BUILD.gn b/video/BUILD.gn index 12a316e69e..97ed9655a8 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -170,6 +170,7 @@ rtc_library("video_stream_decoder_impl") { "../modules/video_coding", "../rtc_base:rtc_base_approved", "../rtc_base:rtc_task_queue", + "../rtc_base/synchronization:mutex", "../system_wrappers", ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] diff --git a/video/video_stream_decoder_impl.cc b/video/video_stream_decoder_impl.cc index 1e11d38050..02ba45e253 100644 --- a/video/video_stream_decoder_impl.cc +++ b/video/video_stream_decoder_impl.cc @@ -47,7 +47,7 @@ VideoStreamDecoderImpl::VideoStreamDecoderImpl( } VideoStreamDecoderImpl::~VideoStreamDecoderImpl() { - rtc::CritScope lock(&shut_down_crit_); + MutexLock lock(&shut_down_mutex_); shut_down_ = true; } @@ -157,7 +157,7 @@ void VideoStreamDecoderImpl::OnNextFrameCallback( RTC_DCHECK(frame); SaveFrameTimestamps(*frame); - rtc::CritScope lock(&shut_down_crit_); + MutexLock lock(&shut_down_mutex_); if (shut_down_) { return; } diff --git a/video/video_stream_decoder_impl.h b/video/video_stream_decoder_impl.h index 4163afe243..2f33e9d349 100644 --- a/video/video_stream_decoder_impl.h +++ b/video/video_stream_decoder_impl.h @@ -19,8 +19,8 @@ #include "api/video/video_stream_decoder.h" #include "modules/video_coding/frame_buffer2.h" #include "modules/video_coding/timing.h" -#include "rtc_base/critical_section.h" #include "rtc_base/platform_thread.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue.h" #include "rtc_base/thread_checker.h" #include "system_wrappers/include/clock.h" @@ -113,8 +113,8 @@ class VideoStreamDecoderImpl : public VideoStreamDecoderInterface { // safe for the |decode_queue_| to be destructed. After that the |decoder_| // can be destructed, and then the |bookkeeping_queue_|. Finally the // |frame_buffer_| can be destructed. - rtc::CriticalSection shut_down_crit_; - bool shut_down_ RTC_GUARDED_BY(shut_down_crit_); + Mutex shut_down_mutex_; + bool shut_down_ RTC_GUARDED_BY(shut_down_mutex_); video_coding::FrameBuffer frame_buffer_ RTC_GUARDED_BY(bookkeeping_queue_); rtc::TaskQueue bookkeeping_queue_; std::unique_ptr decoder_ RTC_GUARDED_BY(decode_queue_);