Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: webrtc/voice_engine/transmit_mixer.cc

Issue 1466353003: Work around data race in TransmitMixer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/transmit_mixer.cc
diff --git a/webrtc/voice_engine/transmit_mixer.cc b/webrtc/voice_engine/transmit_mixer.cc
index b237414b81a3eeff6499b87295910feeaa622718..3af4c07ed3b298227cbeb0b664a17bb6dd26c326 100644
--- a/webrtc/voice_engine/transmit_mixer.cc
+++ b/webrtc/voice_engine/transmit_mixer.cc
@@ -23,8 +23,6 @@
#include "webrtc/voice_engine/utility.h"
#include "webrtc/voice_engine/voe_base_impl.h"
-#define WEBRTC_ABS(a) (((a) < 0) ? -(a) : (a))
-
namespace webrtc {
namespace voe {
@@ -36,12 +34,20 @@ TransmitMixer::OnPeriodicProcess()
"TransmitMixer::OnPeriodicProcess()");
#if defined(WEBRTC_VOICE_ENGINE_TYPING_DETECTION)
- if (_typingNoiseWarningPending)
+ bool send_typing_noise_warning = false;
+ bool typing_noise_detected = false;
{
+ CriticalSectionScoped cs(&_critSect);
+ if (_typingNoiseWarningPending) {
+ send_typing_noise_warning = true;
+ typing_noise_detected = _typingNoiseDetected;
+ _typingNoiseWarningPending = false;
+ }
+ }
+ if (send_typing_noise_warning) {
CriticalSectionScoped cs(&_callbackCritSect);
- if (_voiceEngineObserverPtr)
- {
- if (_typingNoiseDetected) {
+ if (_voiceEngineObserverPtr) {
+ if (typing_noise_detected) {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
"TransmitMixer::OnPeriodicProcess() => "
"CallbackOnError(VE_TYPING_NOISE_WARNING)");
@@ -57,7 +63,6 @@ TransmitMixer::OnPeriodicProcess()
VE_TYPING_NOISE_OFF_WARNING);
}
}
- _typingNoiseWarningPending = false;
}
#endif
@@ -1279,9 +1284,11 @@ void TransmitMixer::TypingDetection(bool keyPressed)
bool vadActive = _audioFrame.vad_activity_ == AudioFrame::kVadActive;
if (_typingDetection.Process(keyPressed, vadActive)) {
+ CriticalSectionScoped cs(&_critSect);
_typingNoiseWarningPending = true;
_typingNoiseDetected = true;
} else {
+ CriticalSectionScoped cs(&_critSect);
// If there is already a warning pending, do not change the state.
// Otherwise set a warning pending if last callback was for noise detected.
if (!_typingNoiseWarningPending && _typingNoiseDetected) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698