From 9bd49becc1e65b5b7575750a25ad135d1d1bedfd Mon Sep 17 00:00:00 2001 From: "turaj@webrtc.org" Date: Tue, 29 Apr 2014 20:27:45 +0000 Subject: [PATCH] Fix a data race in ACM1 when audio is pulled. BUG=chromium:348511 R=henrik.lundin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/13389004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6026 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/source/audio_coding_module_impl.cc | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc index 6ac45d4b18..5bdbd0119f 100644 --- a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc +++ b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc @@ -2250,18 +2250,10 @@ int32_t AudioCodingModuleImpl::PlayoutData10Ms( int decoded_seq_num; uint32_t decoded_timestamp; bool update_nack = - neteq_.DecodedRtpInfo(&decoded_seq_num, &decoded_timestamp) && - nack_enabled_; // Update NACK only if it is enabled. - audio_frame->num_channels_ = audio_frame_.num_channels_; - audio_frame->vad_activity_ = audio_frame_.vad_activity_; - audio_frame->speech_type_ = audio_frame_.speech_type_; + neteq_.DecodedRtpInfo(&decoded_seq_num, &decoded_timestamp); - stereo_mode = (audio_frame_.num_channels_ > 1); - - // For stereo playout: // Master and Slave samples are interleaved starting with Master. - const uint16_t receive_freq = - static_cast(audio_frame_.sample_rate_hz_); + uint16_t receive_freq; bool tone_detected = false; int16_t last_detected_tone; int16_t tone; @@ -2270,10 +2262,17 @@ int32_t AudioCodingModuleImpl::PlayoutData10Ms( { CriticalSectionScoped lock(acm_crit_sect_); + audio_frame->num_channels_ = audio_frame_.num_channels_; + audio_frame->vad_activity_ = audio_frame_.vad_activity_; + audio_frame->speech_type_ = audio_frame_.speech_type_; + + stereo_mode = (audio_frame_.num_channels_ > 1); + + receive_freq = static_cast(audio_frame_.sample_rate_hz_); // Update call statistics. call_stats_.DecodedByNetEq(audio_frame->speech_type_); - if (update_nack) { + if (nack_enabled_ && update_nack) { assert(nack_.get()); nack_->UpdateLastDecodedPacket(decoded_seq_num, decoded_timestamp); }