From 20028c49c91428929c7c0bc5907e2df3119b6937 Mon Sep 17 00:00:00 2001 From: peah Date: Fri, 4 Mar 2016 11:50:54 -0800 Subject: [PATCH] Removing the use of the soon-to-be-removed echo_cancellation_impl api function that directly returns aec_core. BUG=webrtc:5201 Review URL: https://codereview.webrtc.org/1695743004 Cr-Commit-Position: refs/heads/master@{#11875} --- webrtc/modules/audio_processing/audio_processing_impl.cc | 6 ++++-- webrtc/modules/audio_processing/echo_cancellation_impl.cc | 8 ++++++++ webrtc/modules/audio_processing/echo_cancellation_impl.h | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index dbc04b7cf3..a92f13c671 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -1288,10 +1288,12 @@ void AudioProcessingImpl::MaybeUpdateHistograms() { capture_.last_stream_delay_ms = capture_nonlocked_.stream_delay_ms; // Detect a jump in AEC system delay and log the difference. - const int frames_per_ms = + const int samples_per_ms = rtc::CheckedDivExact(capture_nonlocked_.split_rate, 1000); + RTC_DCHECK_LT(0, samples_per_ms); const int aec_system_delay_ms = - WebRtcAec_system_delay(echo_cancellation()->aec_core()) / frames_per_ms; + public_submodules_->echo_cancellation->GetSystemDelayInSamples() / + samples_per_ms; const int diff_aec_system_delay_ms = aec_system_delay_ms - capture_.last_aec_system_delay_ms; if (diff_aec_system_delay_ms > kMinDiffDelayMs && diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/webrtc/modules/audio_processing/echo_cancellation_impl.cc index 1bac629c9e..99def9336c 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.cc +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.cc @@ -421,6 +421,14 @@ int EchoCancellationImpl::Initialize() { return AudioProcessing::kNoError; } +int EchoCancellationImpl::GetSystemDelayInSamples() const { + rtc::CritScope cs(crit_capture_); + RTC_DCHECK(is_component_enabled()); + // Report the delay for the first AEC component. + return WebRtcAec_system_delay( + WebRtcAec_aec_core(static_cast(handle(0)))); +} + void EchoCancellationImpl::AllocateRenderQueue() { const size_t new_render_queue_element_max_size = std::max( static_cast(1), diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.h b/webrtc/modules/audio_processing/echo_cancellation_impl.h index fbc2bcc465..2ef6d52fe6 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.h +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.h @@ -50,6 +50,9 @@ class EchoCancellationImpl : public EchoCancellation, // Called holding the capture lock. void ReadQueuedRenderData(); + // Returns the system delay of the first AEC component. + int GetSystemDelayInSamples() const; + private: // EchoCancellation implementation. int Enable(bool enable) override;