From 9c192b2b06cb012b3f515923aeb0a3a0f9a09025 Mon Sep 17 00:00:00 2001 From: ivoc Date: Thu, 16 Mar 2017 04:22:14 -0700 Subject: [PATCH] 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} --- .../audio_processing/audio_processing_impl.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index 4c9188f768..1f73c5984a 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -1616,10 +1616,14 @@ AudioProcessing::AudioProcessingStatistics AudioProcessingImpl::GetStatistics() 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);