Added locking when getting echo likelihood stats.
Currently no lock is taken when returning echo likelihood stats, which causes a race condition between the thread getting the stats and the thread running the echo detector. This CL resolves the issue by adding locking.
BUG=webrtc:7346
Review-Url: https://codereview.webrtc.org/2749973003
Cr-Commit-Position: refs/heads/master@{#17270}
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index 4c9188f..1f73c59 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -1616,10 +1616,14 @@
metrics.echo_return_loss_enhancement);
stats.residual_echo_return_loss.Set(metrics.residual_echo_return_loss);
}
- stats.residual_echo_likelihood =
- private_submodules_->residual_echo_detector->echo_likelihood();
- stats.residual_echo_likelihood_recent_max =
- private_submodules_->residual_echo_detector->echo_likelihood_recent_max();
+ {
+ rtc::CritScope cs_capture(&crit_capture_);
+ stats.residual_echo_likelihood =
+ private_submodules_->residual_echo_detector->echo_likelihood();
+ stats.residual_echo_likelihood_recent_max =
+ private_submodules_->residual_echo_detector
+ ->echo_likelihood_recent_max();
+ }
public_submodules_->echo_cancellation->GetDelayMetrics(
&stats.delay_median, &stats.delay_standard_deviation,
&stats.fraction_poor_delays);