APM reports AEC3 ERL and ERLE metrics also via the old GetStatistics function.

The audio processing module reports the metrics 'echo return loss'
and 'echo return loss enhancement' for AEC3 via the old, soon to be
replaced, GetStatistics fuction.

Bug: webrtc:8533
Change-Id: I6b2286b5cdf8f20ebf14f82f1180f6bfb6c00c68
Reviewed-on: https://webrtc-review.googlesource.com/25642
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20869}
diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc
index 8dac602..4a39bb9 100644
--- a/modules/audio_processing/audio_processing_impl.cc
+++ b/modules/audio_processing/audio_processing_impl.cc
@@ -1580,8 +1580,16 @@
     const {
   AudioProcessingStatistics stats;
   EchoCancellation::Metrics metrics;
-  if (public_submodules_->echo_cancellation->GetMetrics(&metrics) ==
-      Error::kNoError) {
+  if (private_submodules_->echo_controller) {
+    rtc::CritScope cs_capture(&crit_capture_);
+    auto ec_metrics = private_submodules_->echo_controller->GetMetrics();
+    float erl = static_cast<float>(ec_metrics.echo_return_loss);
+    float erle = static_cast<float>(ec_metrics.echo_return_loss_enhancement);
+    // Instant value will also be used for min, max and average.
+    stats.echo_return_loss.Set(erl, erl, erl, erl);
+    stats.echo_return_loss_enhancement.Set(erle, erle, erle, erle);
+  } else if (public_submodules_->echo_cancellation->GetMetrics(&metrics) ==
+             Error::kNoError) {
     stats.a_nlp.Set(metrics.a_nlp);
     stats.divergent_filter_fraction = metrics.divergent_filter_fraction;
     stats.echo_return_loss.Set(metrics.echo_return_loss);
@@ -1610,12 +1618,10 @@
     EchoCancellation::Metrics metrics;
     if (private_submodules_->echo_controller) {
       rtc::CritScope cs_capture(&crit_capture_);
-      EchoControl::Metrics ec_metrics =
-          private_submodules_->echo_controller->GetMetrics();
-      stats.echo_return_loss =
-          rtc::Optional<double>(ec_metrics.echo_return_loss);
+      auto ec_metrics = private_submodules_->echo_controller->GetMetrics();
+      stats.echo_return_loss = ec_metrics.echo_return_loss;
       stats.echo_return_loss_enhancement =
-          rtc::Optional<double>(ec_metrics.echo_return_loss_enhancement);
+          ec_metrics.echo_return_loss_enhancement;
     } else if (public_submodules_->echo_cancellation->GetMetrics(&metrics) ==
                Error::kNoError) {
       if (metrics.divergent_filter_fraction != -1.0f) {