Swap use of CriticalSectionWrapper with rtc::CriticalSection in voice_engine/
Also remove mischievous tab character!
This is a part of getting rid of CriticalSectionWrapper and makes the code slightly simpler.
BUG=
Review URL: https://codereview.webrtc.org/1607353002
Cr-Commit-Position: refs/heads/master@{#11346}
diff --git a/webrtc/voice_engine/transmit_mixer.cc b/webrtc/voice_engine/transmit_mixer.cc
index 1204b04..1490350 100644
--- a/webrtc/voice_engine/transmit_mixer.cc
+++ b/webrtc/voice_engine/transmit_mixer.cc
@@ -13,7 +13,6 @@
#include "webrtc/base/format_macros.h"
#include "webrtc/base/logging.h"
#include "webrtc/modules/utility/include/audio_frame_operations.h"
-#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/trace.h"
#include "webrtc/voice_engine/channel.h"
@@ -37,7 +36,7 @@
bool send_typing_noise_warning = false;
bool typing_noise_detected = false;
{
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
if (_typingNoiseWarningPending) {
send_typing_noise_warning = true;
typing_noise_detected = _typingNoiseDetected;
@@ -45,7 +44,7 @@
}
}
if (send_typing_noise_warning) {
- CriticalSectionScoped cs(&_callbackCritSect);
+ rtc::CritScope cs(&_callbackCritSect);
if (_voiceEngineObserverPtr) {
if (typing_noise_detected) {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
@@ -71,7 +70,7 @@
// 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);
+ rtc::CritScope cs(&_critSect);
saturationWarning = _saturationWarning;
if (_saturationWarning)
_saturationWarning = false;
@@ -79,7 +78,7 @@
if (saturationWarning)
{
- CriticalSectionScoped cs(&_callbackCritSect);
+ rtc::CritScope cs(&_callbackCritSect);
if (_voiceEngineObserverPtr)
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
@@ -118,7 +117,7 @@
assert(id == _filePlayerId);
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
_filePlaying = false;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
@@ -134,14 +133,14 @@
if (id == _fileRecorderId)
{
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
_fileRecording = false;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"TransmitMixer::RecordFileEnded() => fileRecorder module"
"is shutdown");
} else if (id == _fileCallRecorderId)
{
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
_fileCallRecording = false;
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
"TransmitMixer::RecordFileEnded() => fileCallRecorder"
@@ -193,8 +192,6 @@
_fileRecording(false),
_fileCallRecording(false),
_audioLevel(),
- _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
- _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
_typingNoiseWarningPending(false),
_typingNoiseDetected(false),
@@ -226,7 +223,7 @@
DeRegisterExternalMediaProcessing(kRecordingAllChannelsMixed);
DeRegisterExternalMediaProcessing(kRecordingPreprocessing);
{
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
if (_fileRecorderPtr)
{
_fileRecorderPtr->RegisterModuleFileCallback(NULL);
@@ -249,8 +246,6 @@
_filePlayerPtr = NULL;
}
}
- delete &_critSect;
- delete &_callbackCritSect;
}
int32_t
@@ -276,7 +271,7 @@
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
"TransmitMixer::RegisterVoiceEngineObserver()");
- CriticalSectionScoped cs(&_callbackCritSect);
+ rtc::CritScope cs(&_callbackCritSect);
if (_voiceEngineObserverPtr)
{
@@ -340,7 +335,7 @@
samplesPerSec);
{
- CriticalSectionScoped cs(&_callbackCritSect);
+ rtc::CritScope cs(&_callbackCritSect);
if (external_preproc_ptr_) {
external_preproc_ptr_->Process(-1, kRecordingPreprocessing,
_audioFrame.data_,
@@ -388,7 +383,7 @@
// --- Record to file
bool file_recording = false;
{
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
file_recording = _fileRecording;
}
if (file_recording)
@@ -397,7 +392,7 @@
}
{
- CriticalSectionScoped cs(&_callbackCritSect);
+ rtc::CritScope cs(&_callbackCritSect);
if (external_postproc_ptr_) {
external_postproc_ptr_->Process(-1, kRecordingAllChannelsMixed,
_audioFrame.data_,
@@ -520,7 +515,7 @@
return 0;
}
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
// Destroy the old instance
if (_filePlayerPtr)
@@ -597,7 +592,7 @@
return 0;
}
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
// Destroy the old instance
if (_filePlayerPtr)
@@ -654,7 +649,7 @@
return 0;
}
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
if (_filePlayerPtr->StopPlayingFile() != 0)
{
@@ -686,7 +681,7 @@
"TransmitMixer::StartRecordingMicrophone(fileName=%s)",
fileName);
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
if (_fileRecording)
{
@@ -764,7 +759,7 @@
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
"TransmitMixer::StartRecordingMicrophone()");
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
if (_fileRecording)
{
@@ -841,7 +836,7 @@
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
"TransmitMixer::StopRecordingMicrophone()");
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
if (!_fileRecording)
{
@@ -903,7 +898,7 @@
format = kFileFormatCompressedFile;
}
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
// Destroy the old instance
if (_fileCallRecorderPtr)
@@ -981,7 +976,7 @@
format = kFileFormatCompressedFile;
}
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
// Destroy the old instance
if (_fileCallRecorderPtr)
@@ -1032,7 +1027,7 @@
return -1;
}
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
if (_fileCallRecorderPtr->StopRecording() != 0)
{
@@ -1062,7 +1057,7 @@
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
"TransmitMixer::RegisterExternalMediaProcessing()");
- CriticalSectionScoped cs(&_callbackCritSect);
+ rtc::CritScope cs(&_callbackCritSect);
if (!object) {
return -1;
}
@@ -1082,7 +1077,7 @@
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
"TransmitMixer::DeRegisterExternalMediaProcessing()");
- CriticalSectionScoped cs(&_callbackCritSect);
+ rtc::CritScope cs(&_callbackCritSect);
if (type == kRecordingAllChannelsMixed) {
external_postproc_ptr_ = NULL;
} else if (type == kRecordingPreprocessing) {
@@ -1127,7 +1122,7 @@
bool TransmitMixer::IsRecordingMic()
{
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
return _fileRecording;
}
@@ -1162,7 +1157,7 @@
int32_t TransmitMixer::RecordAudioToFile(
uint32_t mixingFrequency)
{
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
if (_fileRecorderPtr == NULL)
{
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1),
@@ -1189,7 +1184,7 @@
size_t fileSamples(0);
{
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
if (_filePlayerPtr == NULL)
{
WEBRTC_TRACE(kTraceWarning, kTraceVoice,
@@ -1267,7 +1262,7 @@
// Store new capture level. Only updated when analog AGC is enabled.
_captureLevel = agc->stream_analog_level();
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
// Triggers a callback in OnPeriodicProcess().
_saturationWarning |= agc->stream_is_saturated();
}
@@ -1282,11 +1277,11 @@
bool vadActive = _audioFrame.vad_activity_ == AudioFrame::kVadActive;
if (_typingDetection.Process(keyPressed, vadActive)) {
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope cs(&_critSect);
_typingNoiseWarningPending = true;
_typingNoiseDetected = true;
} else {
- CriticalSectionScoped cs(&_critSect);
+ rtc::CritScope 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) {