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}
diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc
index 0caa142..554dead 100644
--- a/modules/audio_processing/audio_processing_impl.cc
+++ b/modules/audio_processing/audio_processing_impl.cc
@@ -1792,8 +1792,10 @@
 
 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() {
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index 33ecf89..d31174a 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -1092,7 +1092,10 @@
 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;
diff --git a/modules/audio_processing/residual_echo_detector.cc b/modules/audio_processing/residual_echo_detector.cc
index cef9b29..f506579 100644
--- a/modules/audio_processing/residual_echo_detector.cc
+++ b/modules/audio_processing/residual_echo_detector.cc
@@ -177,8 +177,10 @@
                               : 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);
diff --git a/modules/audio_processing/residual_echo_detector.h b/modules/audio_processing/residual_echo_detector.h
index e8ae552..5d18ecb 100644
--- a/modules/audio_processing/residual_echo_detector.h
+++ b/modules/audio_processing/residual_echo_detector.h
@@ -37,7 +37,10 @@
   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; }