Remove locks from AECM and move it into private_submodules_

This drops the locks and annotations in EchoControlMobileImpl,
now that the interface is no longer externally accessible.

Additionally, SetEchoPath and GetEchoPath (with surrounding code) is
removed. They are unused.

Bug: webrtc:9929
Change-Id: Ibc6751754614ed39836f6ee6835d7b53dedd828c
Reviewed-on: https://webrtc-review.googlesource.com/c/109025
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25504}
diff --git a/modules/audio_processing/echo_control_mobile_impl.cc b/modules/audio_processing/echo_control_mobile_impl.cc
index 3bfb65f..b9fbf42 100644
--- a/modules/audio_processing/echo_control_mobile_impl.cc
+++ b/modules/audio_processing/echo_control_mobile_impl.cc
@@ -57,10 +57,6 @@
 }
 }  // namespace
 
-size_t EchoControlMobileImpl::echo_path_size_bytes() {
-  return WebRtcAecm_echo_path_size_bytes();
-}
-
 struct EchoControlMobileImpl::StreamProperties {
   StreamProperties() = delete;
   StreamProperties(int sample_rate_hz,
@@ -92,17 +88,10 @@
     return state_;
   }
 
-  void Initialize(int sample_rate_hz,
-                  unsigned char* external_echo_path,
-                  size_t echo_path_size_bytes) {
+  void Initialize(int sample_rate_hz) {
     RTC_DCHECK(state_);
     int error = WebRtcAecm_Init(state_, sample_rate_hz);
     RTC_DCHECK_EQ(AudioProcessing::kNoError, error);
-    if (external_echo_path != NULL) {
-      error = WebRtcAecm_InitEchoPath(state_, external_echo_path,
-                                      echo_path_size_bytes);
-      RTC_DCHECK_EQ(AudioProcessing::kNoError, error);
-    }
   }
 
  private:
@@ -110,27 +99,13 @@
   RTC_DISALLOW_COPY_AND_ASSIGN(Canceller);
 };
 
-EchoControlMobileImpl::EchoControlMobileImpl(rtc::CriticalSection* crit_render,
-                                             rtc::CriticalSection* crit_capture)
-    : crit_render_(crit_render),
-      crit_capture_(crit_capture),
-      routing_mode_(kSpeakerphone),
-      comfort_noise_enabled_(false),
-      external_echo_path_(NULL) {
-  RTC_DCHECK(crit_render);
-  RTC_DCHECK(crit_capture);
-}
+EchoControlMobileImpl::EchoControlMobileImpl()
+    : routing_mode_(kSpeakerphone), comfort_noise_enabled_(false) {}
 
-EchoControlMobileImpl::~EchoControlMobileImpl() {
-  if (external_echo_path_ != NULL) {
-    delete[] external_echo_path_;
-    external_echo_path_ = NULL;
-  }
-}
+EchoControlMobileImpl::~EchoControlMobileImpl() {}
 
 void EchoControlMobileImpl::ProcessRenderAudio(
     rtc::ArrayView<const int16_t> packed_render_audio) {
-  rtc::CritScope cs_capture(crit_capture_);
   if (!enabled_) {
     return;
   }
@@ -183,7 +158,6 @@
 
 int EchoControlMobileImpl::ProcessCaptureAudio(AudioBuffer* audio,
                                                int stream_delay_ms) {
-  rtc::CritScope cs_capture(crit_capture_);
   if (!enabled_) {
     return AudioProcessing::kNoError;
   }
@@ -230,8 +204,6 @@
 
 int EchoControlMobileImpl::Enable(bool enable) {
   // Ensure AEC and AECM are not both enabled.
-  rtc::CritScope cs_render(crit_render_);
-  rtc::CritScope cs_capture(crit_capture_);
   RTC_DCHECK(stream_properties_);
 
   if (enable &&
@@ -254,7 +226,6 @@
 }
 
 bool EchoControlMobileImpl::is_enabled() const {
-  rtc::CritScope cs(crit_capture_);
   return enabled_;
 }
 
@@ -262,90 +233,26 @@
   if (MapSetting(mode) == -1) {
     return AudioProcessing::kBadParameterError;
   }
-
-  {
-    rtc::CritScope cs(crit_capture_);
     routing_mode_ = mode;
-  }
   return Configure();
 }
 
 EchoControlMobileImpl::RoutingMode EchoControlMobileImpl::routing_mode() const {
-  rtc::CritScope cs(crit_capture_);
   return routing_mode_;
 }
 
 int EchoControlMobileImpl::enable_comfort_noise(bool enable) {
-  {
-    rtc::CritScope cs(crit_capture_);
     comfort_noise_enabled_ = enable;
-  }
   return Configure();
 }
 
 bool EchoControlMobileImpl::is_comfort_noise_enabled() const {
-  rtc::CritScope cs(crit_capture_);
   return comfort_noise_enabled_;
 }
 
-int EchoControlMobileImpl::SetEchoPath(const void* echo_path,
-                                       size_t size_bytes) {
-  {
-    rtc::CritScope cs_render(crit_render_);
-    rtc::CritScope cs_capture(crit_capture_);
-    if (echo_path == NULL) {
-      return AudioProcessing::kNullPointerError;
-    }
-    if (size_bytes != echo_path_size_bytes()) {
-      // Size mismatch
-      return AudioProcessing::kBadParameterError;
-    }
-
-    if (external_echo_path_ == NULL) {
-      external_echo_path_ = new unsigned char[size_bytes];
-    }
-    memcpy(external_echo_path_, echo_path, size_bytes);
-  }
-
-  // TODO(peah): Simplify once the Enable function has been removed from
-  // the public APM API.
-  RTC_DCHECK(stream_properties_);
-  Initialize(stream_properties_->sample_rate_hz,
-             stream_properties_->num_reverse_channels,
-             stream_properties_->num_output_channels);
-  return AudioProcessing::kNoError;
-}
-
-int EchoControlMobileImpl::GetEchoPath(void* echo_path,
-                                       size_t size_bytes) const {
-  rtc::CritScope cs(crit_capture_);
-  if (echo_path == NULL) {
-    return AudioProcessing::kNullPointerError;
-  }
-  if (size_bytes != echo_path_size_bytes()) {
-    // Size mismatch
-    return AudioProcessing::kBadParameterError;
-  }
-  if (!enabled_) {
-    return AudioProcessing::kNotEnabledError;
-  }
-
-  // Get the echo path from the first channel
-  int32_t err =
-      WebRtcAecm_GetEchoPath(cancellers_[0]->state(), echo_path, size_bytes);
-  if (err != 0) {
-    return MapError(err);
-  }
-
-  return AudioProcessing::kNoError;
-}
-
 void EchoControlMobileImpl::Initialize(int sample_rate_hz,
                                        size_t num_reverse_channels,
                                        size_t num_output_channels) {
-  rtc::CritScope cs_render(crit_render_);
-  rtc::CritScope cs_capture(crit_capture_);
-
   stream_properties_.reset(new StreamProperties(
       sample_rate_hz, num_reverse_channels, num_output_channels));
 
@@ -365,16 +272,12 @@
     if (!canceller) {
       canceller.reset(new Canceller());
     }
-    canceller->Initialize(sample_rate_hz, external_echo_path_,
-                          echo_path_size_bytes());
+    canceller->Initialize(sample_rate_hz);
   }
-
   Configure();
 }
 
 int EchoControlMobileImpl::Configure() {
-  rtc::CritScope cs_render(crit_render_);
-  rtc::CritScope cs_capture(crit_capture_);
   AecmConfig config;
   config.cngMode = comfort_noise_enabled_;
   config.echoMode = MapSetting(routing_mode_);