Add more parameters to the Initialize function of the echo detector.

Since the echo detector processes both the render and the capture audio streams, it needs to know the sample rates and number of channels of both.

Bug: webrtc:8732
Change-Id: Icd26e561d5dd98bd789a6dfa75f468f3fde06fee
Reviewed-on: https://webrtc-review.googlesource.com/61861
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22436}
This commit is contained in:
Ivo Creusen
2018-03-14 17:13:48 +01:00
committed by Commit Bot
parent bbeb2d5130
commit 647ef09d1e
4 changed files with 16 additions and 6 deletions

View File

@ -1792,8 +1792,10 @@ void AudioProcessingImpl::InitializeGainController2() {
void AudioProcessingImpl::InitializeResidualEchoDetector() {
RTC_DCHECK(private_submodules_->echo_detector);
private_submodules_->echo_detector->Initialize(proc_sample_rate_hz(),
num_proc_channels());
private_submodules_->echo_detector->Initialize(
proc_sample_rate_hz(), num_proc_channels(),
formats_.render_processing_format.sample_rate_hz(),
formats_.render_processing_format.num_channels());
}
void AudioProcessingImpl::InitializePostProcessor() {

View File

@ -1092,7 +1092,10 @@ class CustomProcessing {
class EchoDetector {
public:
// (Re-)Initializes the submodule.
virtual void Initialize(int sample_rate_hz, int num_channels) = 0;
virtual void Initialize(int capture_sample_rate_hz,
int num_capture_channels,
int render_sample_rate_hz,
int num_render_channels) = 0;
// Analysis (not changing) of the render signal.
virtual void AnalyzeRenderAudio(rtc::ArrayView<const float> render_audio) = 0;

View File

@ -177,8 +177,10 @@ void ResidualEchoDetector::AnalyzeCaptureAudio(
: 0;
}
void ResidualEchoDetector::Initialize(int /*sample_rate_hz*/,
int /*num_channels*/) {
void ResidualEchoDetector::Initialize(int /*capture_sample_rate_hz*/,
int /*num_capture_channels*/,
int /*render_sample_rate_hz*/,
int /*num_render_channels*/) {
render_buffer_.Clear();
std::fill(render_power_.begin(), render_power_.end(), 0.f);
std::fill(render_power_mean_.begin(), render_power_mean_.end(), 0.f);

View File

@ -37,7 +37,10 @@ class ResidualEchoDetector : public EchoDetector {
void AnalyzeCaptureAudio(rtc::ArrayView<const float> capture_audio) override;
// This function should be called while holding the capture lock.
void Initialize(int sample_rate_hz, int num_channels) override;
void Initialize(int capture_sample_rate_hz,
int num_capture_channels,
int render_sample_rate_hz,
int num_render_channels) override;
// This function is for testing purposes only.
void SetReliabilityForTest(float value) { reliability_ = value; }