From 95d2f478e9776fd70bf3579d57cce9a7efbc069e Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Thu, 1 Apr 2021 19:14:54 +0200 Subject: [PATCH] Call ChannelManager aec dump methods on the worker thread. Before, the calls went through the signaling thread and blocked while the operation completed on the worker. Bug: webrtc:12601 Change-Id: I58991fa98a55d0fa9304a68bd85bb269f1f123d2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212619 Commit-Queue: Tommi Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/master@{#33615} --- api/peer_connection_factory_proxy.h | 6 +++--- pc/channel_manager.cc | 9 ++++----- pc/peer_connection_factory.cc | 8 ++++---- pc/peer_connection_factory.h | 3 ++- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/api/peer_connection_factory_proxy.h b/api/peer_connection_factory_proxy.h index 9056495655..0eb2b391f4 100644 --- a/api/peer_connection_factory_proxy.h +++ b/api/peer_connection_factory_proxy.h @@ -22,7 +22,7 @@ namespace webrtc { // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods // are called on is an implementation detail. -BEGIN_PRIMARY_PROXY_MAP(PeerConnectionFactory) +BEGIN_PROXY_MAP(PeerConnectionFactory) PROXY_PRIMARY_THREAD_DESTRUCTOR() PROXY_METHOD1(void, SetOptions, const Options&) PROXY_METHOD4(rtc::scoped_refptr, @@ -59,8 +59,8 @@ PROXY_METHOD2(rtc::scoped_refptr, CreateAudioTrack, const std::string&, AudioSourceInterface*) -PROXY_METHOD2(bool, StartAecDump, FILE*, int64_t) -PROXY_METHOD0(void, StopAecDump) +PROXY_SECONDARY_METHOD2(bool, StartAecDump, FILE*, int64_t) +PROXY_SECONDARY_METHOD0(void, StopAecDump) END_PROXY_MAP() } // namespace webrtc diff --git a/pc/channel_manager.cc b/pc/channel_manager.cc index 75e728aa34..3fc0cd191b 100644 --- a/pc/channel_manager.cc +++ b/pc/channel_manager.cc @@ -360,14 +360,13 @@ bool ChannelManager::has_channels() const { bool ChannelManager::StartAecDump(webrtc::FileWrapper file, int64_t max_size_bytes) { - return worker_thread_->Invoke(RTC_FROM_HERE, [&] { - return media_engine_->voice().StartAecDump(std::move(file), max_size_bytes); - }); + RTC_DCHECK_RUN_ON(worker_thread_); + return media_engine_->voice().StartAecDump(std::move(file), max_size_bytes); } void ChannelManager::StopAecDump() { - worker_thread_->Invoke(RTC_FROM_HERE, - [&] { media_engine_->voice().StopAecDump(); }); + RTC_DCHECK_RUN_ON(worker_thread_); + media_engine_->voice().StopAecDump(); } } // namespace cricket diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index ee5c74f272..c911871f8d 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -73,8 +73,8 @@ CreateModularPeerConnectionFactory( // Verify that the invocation and the initialization ended up agreeing on the // thread. RTC_DCHECK_RUN_ON(pc_factory->signaling_thread()); - return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), - pc_factory); + return PeerConnectionFactoryProxy::Create( + pc_factory->signaling_thread(), pc_factory->worker_thread(), pc_factory); } // Static @@ -176,12 +176,12 @@ PeerConnectionFactory::CreateAudioSource(const cricket::AudioOptions& options) { } bool PeerConnectionFactory::StartAecDump(FILE* file, int64_t max_size_bytes) { - RTC_DCHECK(signaling_thread()->IsCurrent()); + RTC_DCHECK_RUN_ON(worker_thread()); return channel_manager()->StartAecDump(FileWrapper(file), max_size_bytes); } void PeerConnectionFactory::StopAecDump() { - RTC_DCHECK(signaling_thread()->IsCurrent()); + RTC_DCHECK_RUN_ON(worker_thread()); channel_manager()->StopAecDump(); } diff --git a/pc/peer_connection_factory.h b/pc/peer_connection_factory.h index cbc7397c3f..71d78309bf 100644 --- a/pc/peer_connection_factory.h +++ b/pc/peer_connection_factory.h @@ -117,6 +117,8 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { return context_->signaling_thread(); } + rtc::Thread* worker_thread() const { return context_->worker_thread(); } + const Options& options() const { RTC_DCHECK_RUN_ON(signaling_thread()); return options_; @@ -137,7 +139,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { virtual ~PeerConnectionFactory(); private: - rtc::Thread* worker_thread() const { return context_->worker_thread(); } rtc::Thread* network_thread() const { return context_->network_thread(); } bool IsTrialEnabled(absl::string_view key) const;