diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index 953b6996cc..0f48fa5e18 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -1157,9 +1157,11 @@ bool AudioProcessingImpl::rev_synthesis_needed() const { bool AudioProcessingImpl::rev_analysis_needed() const { return formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz && (is_rev_processed() || - public_submodules_->echo_cancellation->is_enabled() || - public_submodules_->echo_control_mobile->is_enabled() || - public_submodules_->gain_control->is_enabled()); + public_submodules_->echo_cancellation + ->is_enabled_render_side_query() || + public_submodules_->echo_control_mobile + ->is_enabled_render_side_query() || + public_submodules_->gain_control->is_enabled_render_side_query()); } bool AudioProcessingImpl::render_check_rev_conversion_needed() const { diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/webrtc/modules/audio_processing/echo_cancellation_impl.cc index a323736a56..168391145f 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.cc +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.cc @@ -275,6 +275,12 @@ int EchoCancellationImpl::Enable(bool enable) { return AudioProcessing::kNoError; } +bool EchoCancellationImpl::is_enabled_render_side_query() const { + // TODO(peah): Add threadchecker. + rtc::CritScope cs_render(crit_render_); + return enabled_; +} + bool EchoCancellationImpl::is_enabled() const { rtc::CritScope cs(crit_capture_); return enabled_; diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.h b/webrtc/modules/audio_processing/echo_cancellation_impl.h index b91d23d823..813019f424 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.h +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.h @@ -48,6 +48,11 @@ class EchoCancellationImpl : public EchoCancellation { bool is_extended_filter_enabled() const; bool is_aec3_enabled() const; + // Checks whether the module is enabled. Must only be + // called from the render side of APM as otherwise + // deadlocks may occur. + bool is_enabled_render_side_query() const; + // Reads render side data that has been queued on the render call. // Called holding the capture lock. void ReadQueuedRenderData(); diff --git a/webrtc/modules/audio_processing/echo_control_mobile_impl.cc b/webrtc/modules/audio_processing/echo_control_mobile_impl.cc index 2d5ba35c34..97f69974db 100644 --- a/webrtc/modules/audio_processing/echo_control_mobile_impl.cc +++ b/webrtc/modules/audio_processing/echo_control_mobile_impl.cc @@ -278,6 +278,12 @@ int EchoControlMobileImpl::Enable(bool enable) { return AudioProcessing::kNoError; } +bool EchoControlMobileImpl::is_enabled_render_side_query() const { + // TODO(peah): Add threadchecker. + rtc::CritScope cs_render(crit_render_); + return enabled_; +} + bool EchoControlMobileImpl::is_enabled() const { rtc::CritScope cs(crit_capture_); return enabled_; diff --git a/webrtc/modules/audio_processing/echo_control_mobile_impl.h b/webrtc/modules/audio_processing/echo_control_mobile_impl.h index c59a69610d..97e24075de 100644 --- a/webrtc/modules/audio_processing/echo_control_mobile_impl.h +++ b/webrtc/modules/audio_processing/echo_control_mobile_impl.h @@ -43,6 +43,11 @@ class EchoControlMobileImpl : public EchoControlMobile { size_t num_reverse_channels, size_t num_output_channels); + // Checks whether the module is enabled. Must only be + // called from the render side of APM as otherwise + // deadlocks may occur. + bool is_enabled_render_side_query() const; + // Reads render side data that has been queued on the render call. void ReadQueuedRenderData(); diff --git a/webrtc/modules/audio_processing/gain_control_impl.cc b/webrtc/modules/audio_processing/gain_control_impl.cc index d190284063..3a6fcb116d 100644 --- a/webrtc/modules/audio_processing/gain_control_impl.cc +++ b/webrtc/modules/audio_processing/gain_control_impl.cc @@ -310,6 +310,12 @@ int GainControlImpl::Enable(bool enable) { return AudioProcessing::kNoError; } +bool GainControlImpl::is_enabled_render_side_query() const { + // TODO(peah): Add threadchecker. + rtc::CritScope cs(crit_render_); + return enabled_; +} + bool GainControlImpl::is_enabled() const { rtc::CritScope cs(crit_capture_); return enabled_; diff --git a/webrtc/modules/audio_processing/gain_control_impl.h b/webrtc/modules/audio_processing/gain_control_impl.h index a7e787417c..9498ac60b5 100644 --- a/webrtc/modules/audio_processing/gain_control_impl.h +++ b/webrtc/modules/audio_processing/gain_control_impl.h @@ -43,6 +43,11 @@ class GainControlImpl : public GainControl { bool is_limiter_enabled() const override; Mode mode() const override; + // Checks whether the module is enabled. Must only be + // called from the render side of APM as otherwise + // deadlocks may occur. + bool is_enabled_render_side_query() const; + // Reads render side data that has been queued on the render call. void ReadQueuedRenderData();