summaryrefslogtreecommitdiff
path: root/voice_engine/transmit_mixer.cc
diff options
context:
space:
mode:
authorhenrika@webrtc.org <henrika@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2013-04-04 08:39:09 +0000
committerhenrika@webrtc.org <henrika@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2013-04-04 08:39:09 +0000
commit45ce6a8bf29d016932496bcdd6e125f4e2003d71 (patch)
treed4fc4f9eec95bd0fe271e65073f96d839a3f854b /voice_engine/transmit_mixer.cc
parente4932183091c42119e819bac6c6426f906438fa4 (diff)
downloadwebrtc-45ce6a8bf29d016932496bcdd6e125f4e2003d71.tar.gz
TSan v2 reports data races in WebRTCAudioDeviceTest.FullDuplexAudioWithAGC
BUG=226044 TEST=content_unittests in Chrome with TSan v2 enabled Review URL: https://webrtc-codereview.appspot.com/1201010 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@3760 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'voice_engine/transmit_mixer.cc')
-rw-r--r--voice_engine/transmit_mixer.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/voice_engine/transmit_mixer.cc b/voice_engine/transmit_mixer.cc
index 242b965c..0e4717c2 100644
--- a/voice_engine/transmit_mixer.cc
+++ b/voice_engine/transmit_mixer.cc
@@ -56,7 +56,18 @@ TransmitMixer::OnPeriodicProcess()
}
#endif
- if (_saturationWarning)
+ bool saturationWarning = false;
+ {
+ // Modify |_saturationWarning| under lock to avoid conflict with write op
+ // in ProcessAudio and also ensure that we don't hold the lock during the
+ // callback.
+ CriticalSectionScoped cs(&_critSect);
+ saturationWarning = _saturationWarning;
+ if (_saturationWarning)
+ _saturationWarning = false;
+ }
+
+ if (saturationWarning)
{
CriticalSectionScoped cs(&_callbackCritSect);
if (_voiceEngineObserverPtr)
@@ -66,7 +77,6 @@ TransmitMixer::OnPeriodicProcess()
" CallbackOnError(VE_SATURATION_WARNING)");
_voiceEngineObserverPtr->CallbackOnError(-1, VE_SATURATION_WARNING);
}
- _saturationWarning = false;
}
}
@@ -454,6 +464,7 @@ TransmitMixer::EncodeAndSend()
WebRtc_UWord32 TransmitMixer::CaptureLevel() const
{
+ CriticalSectionScoped cs(&_critSect);
return _captureLevel;
}
@@ -1311,6 +1322,8 @@ void TransmitMixer::ProcessAudio(int delay_ms, int clock_drift,
LOG(LS_ERROR) << "ProcessStream() error: " << err;
}
+ CriticalSectionScoped cs(&_critSect);
+
// Store new capture level. Only updated when analog AGC is enabled.
_captureLevel = agc->stream_analog_level();