Removes usage of analog AGC.

AGC APIs have recently been removed from the ADM.
This CL ensures that usage of the analog part of the AGC is removed
as well (since this code is dead today anyhow).

Bug: webrtc:7306, webrtc:8598
Change-Id: I144f01cd545e5ff6900707c9308906081914e413
Reviewed-on: https://webrtc-review.googlesource.com/36120
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21640}
diff --git a/audio/audio_state.cc b/audio/audio_state.cc
index 24a7ce8..06a686331 100644
--- a/audio/audio_state.cc
+++ b/audio/audio_state.cc
@@ -28,8 +28,7 @@
 AudioState::AudioState(const AudioState::Config& config)
     : config_(config),
       audio_transport_(config_.audio_mixer,
-                       config_.audio_processing.get(),
-                       config_.audio_device_module.get()) {
+                       config_.audio_processing.get()) {
   process_thread_checker_.DetachFromThread();
   RTC_DCHECK(config_.audio_mixer);
   RTC_DCHECK(config_.audio_device_module);
diff --git a/audio/audio_transport_impl.cc b/audio/audio_transport_impl.cc
index 586fc46..30ffc6d 100644
--- a/audio/audio_transport_impl.cc
+++ b/audio/audio_transport_impl.cc
@@ -43,8 +43,7 @@
   audio_frame->num_channels_ = std::min(input_num_channels, send_num_channels);
 }
 
-void ProcessCaptureFrame(int analog_level,
-                         uint32_t delay_ms,
+void ProcessCaptureFrame(uint32_t delay_ms,
                          bool key_pressed,
                          bool swap_stereo_channels,
                          AudioProcessing* audio_processing,
@@ -53,13 +52,9 @@
   RTC_DCHECK(audio_frame);
   RTC_DCHECK(
       !audio_processing->echo_cancellation()->is_drift_compensation_enabled());
-  GainControl* agc = audio_processing->gain_control();
-  int error = agc->set_stream_analog_level(analog_level);
-  RTC_DCHECK_EQ(0, error) <<
-      "set_stream_analog_level failed: analog_level = " << analog_level;
   audio_processing->set_stream_delay_ms(delay_ms);
   audio_processing->set_stream_key_pressed(key_pressed);
-  error = audio_processing->ProcessStream(audio_frame);
+  int error = audio_processing->ProcessStream(audio_frame);
   RTC_DCHECK_EQ(0, error) << "ProcessStream() error: " << error;
   if (swap_stereo_channels) {
     AudioFrameOperations::SwapStereoChannels(audio_frame);
@@ -87,14 +82,11 @@
 }  // namespace
 
 AudioTransportImpl::AudioTransportImpl(AudioMixer* mixer,
-                                       AudioProcessing* audio_processing,
-                                       AudioDeviceModule* audio_device_module)
+                                       AudioProcessing* audio_processing)
     : audio_processing_(audio_processing),
-      audio_device_module_(audio_device_module),
       mixer_(mixer) {
   RTC_DCHECK(mixer);
   RTC_DCHECK(audio_processing);
-  RTC_DCHECK(audio_device_module);
 }
 
 AudioTransportImpl::~AudioTransportImpl() {}
@@ -109,7 +101,7 @@
     const uint32_t sample_rate,
     const uint32_t audio_delay_milliseconds,
     const int32_t /*clock_drift*/,
-    const uint32_t volume,
+    const uint32_t /*volume*/,
     const bool key_pressed,
     uint32_t& /*new_mic_volume*/) {  // NOLINT: to avoid changing APIs
   RTC_DCHECK(audio_data);
@@ -122,35 +114,6 @@
   RTC_DCHECK_LE(bytes_per_sample * number_of_frames * number_of_channels,
                 AudioFrame::kMaxDataSizeBytes);
 
-  // TODO(solenberg): Remove volume handling since it is now always 0.
-  uint16_t voe_mic_level = 0;
-  {
-    constexpr uint32_t kMaxVolumeLevel = 255;
-    uint32_t max_volume = 0;
-
-    // Check for zero to skip this calculation; the consumer may use this to
-    // indicate no volume is available.
-    if (volume != 0) {
-      // Scale from ADM to VoE level range
-      if (audio_device_module_->MaxMicrophoneVolume(&max_volume) == 0) {
-        if (max_volume != 0) {
-          voe_mic_level = static_cast<uint16_t>(
-              (volume * kMaxVolumeLevel + static_cast<int>(max_volume / 2)) /
-              max_volume);
-        }
-      }
-      // We learned that on certain systems (e.g Linux) the voe_mic_level
-      // can be greater than the maxVolumeLevel therefore
-      // we are going to cap the voe_mic_level to the maxVolumeLevel
-      // and change the maxVolume to volume if it turns out that
-      // the voe_mic_level is indeed greater than the maxVolumeLevel.
-      if (voe_mic_level > kMaxVolumeLevel) {
-        voe_mic_level = kMaxVolumeLevel;
-        max_volume = volume;
-      }
-    }
-  }
-
   int send_sample_rate_hz = 0;
   size_t send_num_channels = 0;
   bool swap_stereo_channels = false;
@@ -168,7 +131,7 @@
   voe::RemixAndResample(static_cast<const int16_t*>(audio_data),
                         number_of_frames, number_of_channels, sample_rate,
                         &capture_resampler_, audio_frame.get());
-  ProcessCaptureFrame(voe_mic_level, audio_delay_milliseconds, key_pressed,
+  ProcessCaptureFrame(audio_delay_milliseconds, key_pressed,
                       swap_stereo_channels, audio_processing_,
                       audio_frame.get());
 
diff --git a/audio/audio_transport_impl.h b/audio/audio_transport_impl.h
index e7de7e9..8a316a5 100644
--- a/audio/audio_transport_impl.h
+++ b/audio/audio_transport_impl.h
@@ -31,8 +31,7 @@
 class AudioTransportImpl : public AudioTransport {
  public:
   AudioTransportImpl(AudioMixer* mixer,
-                     AudioProcessing* audio_processing,
-                     AudioDeviceModule* audio_device_module);
+                     AudioProcessing* audio_processing);
   ~AudioTransportImpl() override;
 
   int32_t RecordedDataIsAvailable(const void* audioSamples,
@@ -82,7 +81,6 @@
   size_t send_num_channels_ RTC_GUARDED_BY(capture_lock_) = 1;
   bool typing_noise_detected_ RTC_GUARDED_BY(capture_lock_) = false;
   bool swap_stereo_channels_ RTC_GUARDED_BY(capture_lock_) = false;
-  AudioDeviceModule* audio_device_module_ = nullptr;
   PushResampler<int16_t> capture_resampler_;
   voe::AudioLevel audio_level_;
   TypingDetection typing_detection_;