diff options
author | Markus Handell <handellm@webrtc.org> | 2020-07-06 17:41:35 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-06 15:48:30 +0000 |
commit | 8fe932a5a3686ec21b8c6d5b0efcdc21d253f7a0 (patch) | |
tree | ec1e031f68994cc0072d61f2107c85065c05b4de /call/adaptation | |
parent | 6287280d64ece74c22a0d8dde9e20bd23e68374e (diff) | |
download | webrtc-8fe932a5a3686ec21b8c6d5b0efcdc21d253f7a0.tar.gz |
Migrate call/ to webrtc::Mutex.
Bug: webrtc:11567
Change-Id: Iab7142c77bc0c1a026cf5121b756094e05bccefe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176742
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31636}
Diffstat (limited to 'call/adaptation')
-rw-r--r-- | call/adaptation/BUILD.gn | 2 | ||||
-rw-r--r-- | call/adaptation/broadcast_resource_listener.cc | 20 | ||||
-rw-r--r-- | call/adaptation/broadcast_resource_listener.h | 4 | ||||
-rw-r--r-- | call/adaptation/resource_adaptation_processor_unittest.cc | 2 | ||||
-rw-r--r-- | call/adaptation/video_stream_input_state_provider.cc | 8 | ||||
-rw-r--r-- | call/adaptation/video_stream_input_state_provider.h | 6 |
6 files changed, 22 insertions, 20 deletions
diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn index 084b7bd856..6aa82e5780 100644 --- a/call/adaptation/BUILD.gn +++ b/call/adaptation/BUILD.gn @@ -49,6 +49,7 @@ rtc_library("resource_adaptation") { "../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_task_queue", "../../rtc_base/experiments:balanced_degradation_settings", + "../../rtc_base/synchronization:mutex", "../../rtc_base/synchronization:sequence_checker", "../../rtc_base/task_utils:to_queued_task", ] @@ -85,6 +86,7 @@ if (rtc_include_tests) { "../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_task_queue", "../../rtc_base:task_queue_for_test", + "../../rtc_base/synchronization:mutex", "../../test:field_trial", "../../test:rtc_expect_death", "../../test:test_support", diff --git a/call/adaptation/broadcast_resource_listener.cc b/call/adaptation/broadcast_resource_listener.cc index 2a4d8cab09..59bd1e0c7f 100644 --- a/call/adaptation/broadcast_resource_listener.cc +++ b/call/adaptation/broadcast_resource_listener.cc @@ -15,8 +15,8 @@ #include <utility> #include "rtc_base/checks.h" -#include "rtc_base/critical_section.h" #include "rtc_base/ref_counted_object.h" +#include "rtc_base/synchronization/mutex.h" namespace webrtc { @@ -29,7 +29,7 @@ class BroadcastResourceListener::AdapterResource : public Resource { // The parent is letting us know we have a usage neasurement. void OnResourceUsageStateMeasured(ResourceUsageState usage_state) { - rtc::CritScope crit(&lock_); + MutexLock lock(&lock_); if (!listener_) return; listener_->OnResourceUsageStateMeasured(this, usage_state); @@ -38,14 +38,14 @@ class BroadcastResourceListener::AdapterResource : public Resource { // Resource implementation. std::string Name() const override { return name_; } void SetResourceListener(ResourceListener* listener) override { - rtc::CritScope crit(&lock_); + MutexLock lock(&lock_); RTC_DCHECK(!listener_ || !listener); listener_ = listener; } private: const std::string name_; - rtc::CriticalSection lock_; + Mutex lock_; ResourceListener* listener_ RTC_GUARDED_BY(lock_) = nullptr; }; @@ -64,14 +64,14 @@ rtc::scoped_refptr<Resource> BroadcastResourceListener::SourceResource() const { } void BroadcastResourceListener::StartListening() { - rtc::CritScope crit(&lock_); + MutexLock lock(&lock_); RTC_DCHECK(!is_listening_); source_resource_->SetResourceListener(this); is_listening_ = true; } void BroadcastResourceListener::StopListening() { - rtc::CritScope crit(&lock_); + MutexLock lock(&lock_); RTC_DCHECK(is_listening_); RTC_DCHECK(adapters_.empty()); source_resource_->SetResourceListener(nullptr); @@ -80,7 +80,7 @@ void BroadcastResourceListener::StopListening() { rtc::scoped_refptr<Resource> BroadcastResourceListener::CreateAdapterResource() { - rtc::CritScope crit(&lock_); + MutexLock lock(&lock_); RTC_DCHECK(is_listening_); rtc::scoped_refptr<AdapterResource> adapter = new rtc::RefCountedObject<AdapterResource>(source_resource_->Name() + @@ -91,7 +91,7 @@ BroadcastResourceListener::CreateAdapterResource() { void BroadcastResourceListener::RemoveAdapterResource( rtc::scoped_refptr<Resource> resource) { - rtc::CritScope crit(&lock_); + MutexLock lock(&lock_); auto it = std::find(adapters_.begin(), adapters_.end(), resource); RTC_DCHECK(it != adapters_.end()); adapters_.erase(it); @@ -100,7 +100,7 @@ void BroadcastResourceListener::RemoveAdapterResource( std::vector<rtc::scoped_refptr<Resource>> BroadcastResourceListener::GetAdapterResources() { std::vector<rtc::scoped_refptr<Resource>> resources; - rtc::CritScope crit(&lock_); + MutexLock lock(&lock_); for (const auto& adapter : adapters_) { resources.push_back(adapter); } @@ -111,7 +111,7 @@ void BroadcastResourceListener::OnResourceUsageStateMeasured( rtc::scoped_refptr<Resource> resource, ResourceUsageState usage_state) { RTC_DCHECK_EQ(resource, source_resource_); - rtc::CritScope crit(&lock_); + MutexLock lock(&lock_); for (const auto& adapter : adapters_) { adapter->OnResourceUsageStateMeasured(usage_state); } diff --git a/call/adaptation/broadcast_resource_listener.h b/call/adaptation/broadcast_resource_listener.h index f0d035dab7..2c5a5c703b 100644 --- a/call/adaptation/broadcast_resource_listener.h +++ b/call/adaptation/broadcast_resource_listener.h @@ -15,7 +15,7 @@ #include "api/adaptation/resource.h" #include "api/scoped_refptr.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/synchronization/mutex.h" namespace webrtc { @@ -62,7 +62,7 @@ class BroadcastResourceListener : public ResourceListener { friend class AdapterResource; const rtc::scoped_refptr<Resource> source_resource_; - rtc::CriticalSection lock_; + Mutex lock_; bool is_listening_ RTC_GUARDED_BY(lock_); // The AdapterResource unregisters itself prior to destruction, guaranteeing // that these pointers are safe to use. diff --git a/call/adaptation/resource_adaptation_processor_unittest.cc b/call/adaptation/resource_adaptation_processor_unittest.cc index 4e0f88524b..e7298d6e3c 100644 --- a/call/adaptation/resource_adaptation_processor_unittest.cc +++ b/call/adaptation/resource_adaptation_processor_unittest.cc @@ -20,9 +20,9 @@ #include "call/adaptation/test/fake_resource.h" #include "call/adaptation/video_source_restrictions.h" #include "call/adaptation/video_stream_input_state_provider.h" -#include "rtc_base/critical_section.h" #include "rtc_base/event.h" #include "rtc_base/gunit.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue_for_test.h" #include "test/gtest.h" diff --git a/call/adaptation/video_stream_input_state_provider.cc b/call/adaptation/video_stream_input_state_provider.cc index 4ecf858a11..3c0a7e3fa2 100644 --- a/call/adaptation/video_stream_input_state_provider.cc +++ b/call/adaptation/video_stream_input_state_provider.cc @@ -19,19 +19,19 @@ VideoStreamInputStateProvider::VideoStreamInputStateProvider( VideoStreamInputStateProvider::~VideoStreamInputStateProvider() {} void VideoStreamInputStateProvider::OnHasInputChanged(bool has_input) { - rtc::CritScope lock(&crit_); + MutexLock lock(&mutex_); input_state_.set_has_input(has_input); } void VideoStreamInputStateProvider::OnFrameSizeObserved(int frame_size_pixels) { RTC_DCHECK_GT(frame_size_pixels, 0); - rtc::CritScope lock(&crit_); + MutexLock lock(&mutex_); input_state_.set_frame_size_pixels(frame_size_pixels); } void VideoStreamInputStateProvider::OnEncoderSettingsChanged( EncoderSettings encoder_settings) { - rtc::CritScope lock(&crit_); + MutexLock lock(&mutex_); input_state_.set_video_codec_type( encoder_settings.encoder_config().codec_type); input_state_.set_min_pixels_per_frame( @@ -41,7 +41,7 @@ void VideoStreamInputStateProvider::OnEncoderSettingsChanged( VideoStreamInputState VideoStreamInputStateProvider::InputState() { // GetInputFrameRate() is thread-safe. int input_fps = frame_rate_provider_->GetInputFrameRate(); - rtc::CritScope lock(&crit_); + MutexLock lock(&mutex_); input_state_.set_frames_per_second(input_fps); return input_state_; } diff --git a/call/adaptation/video_stream_input_state_provider.h b/call/adaptation/video_stream_input_state_provider.h index a20ac1788a..f4a3e0bfa0 100644 --- a/call/adaptation/video_stream_input_state_provider.h +++ b/call/adaptation/video_stream_input_state_provider.h @@ -14,7 +14,7 @@ #include "api/video/video_stream_encoder_observer.h" #include "call/adaptation/encoder_settings.h" #include "call/adaptation/video_stream_input_state.h" -#include "rtc_base/critical_section.h" +#include "rtc_base/synchronization/mutex.h" namespace webrtc { @@ -31,9 +31,9 @@ class VideoStreamInputStateProvider { virtual VideoStreamInputState InputState(); private: - mutable rtc::CriticalSection crit_; + Mutex mutex_; VideoStreamEncoderObserver* const frame_rate_provider_; - VideoStreamInputState input_state_ RTC_GUARDED_BY(crit_); + VideoStreamInputState input_state_ RTC_GUARDED_BY(mutex_); }; } // namespace webrtc |