Add multi-channel support to AECM

AECM only supports up to two capture channels, this CL extends it to arbitrary channel counts.

Bug: webrtc:10859
Change-Id: Id56ca633cd9de706fa1254bfa8153de88de0ef70
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160340
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29880}
diff --git a/modules/audio_processing/echo_control_mobile_impl.cc b/modules/audio_processing/echo_control_mobile_impl.cc
index 8057e33..6221aec 100644
--- a/modules/audio_processing/echo_control_mobile_impl.cc
+++ b/modules/audio_processing/echo_control_mobile_impl.cc
@@ -102,10 +102,7 @@
 };
 
 EchoControlMobileImpl::EchoControlMobileImpl()
-    : routing_mode_(kSpeakerphone), comfort_noise_enabled_(false) {
-  low_pass_reference_[0].fill(0);
-  low_pass_reference_[1].fill(0);
-}
+    : routing_mode_(kSpeakerphone), comfort_noise_enabled_(false) {}
 
 EchoControlMobileImpl::~EchoControlMobileImpl() {}
 
@@ -257,8 +254,10 @@
 void EchoControlMobileImpl::Initialize(int sample_rate_hz,
                                        size_t num_reverse_channels,
                                        size_t num_output_channels) {
-  low_pass_reference_[0].fill(0);
-  low_pass_reference_[1].fill(0);
+  low_pass_reference_.resize(num_output_channels);
+  for (auto& reference : low_pass_reference_) {
+    reference.fill(0);
+  }
 
   stream_properties_.reset(new StreamProperties(
       sample_rate_hz, num_reverse_channels, num_output_channels));
diff --git a/modules/audio_processing/echo_control_mobile_impl.h b/modules/audio_processing/echo_control_mobile_impl.h
index 718819d..f12ce2a 100644
--- a/modules/audio_processing/echo_control_mobile_impl.h
+++ b/modules/audio_processing/echo_control_mobile_impl.h
@@ -79,7 +79,7 @@
 
   std::vector<std::unique_ptr<Canceller>> cancellers_;
   std::unique_ptr<StreamProperties> stream_properties_;
-  std::array<std::array<int16_t, 160>, 2> low_pass_reference_;
+  std::vector<std::array<int16_t, 160>> low_pass_reference_;
   bool reference_copied_ = false;
 };
 }  // namespace webrtc