Index: webrtc/modules/audio_device/win/audio_device_core_win.cc |
diff --git a/webrtc/modules/audio_device/win/audio_device_core_win.cc b/webrtc/modules/audio_device/win/audio_device_core_win.cc |
index 8b38b94f6227872bfa98e3fa5a9925ea83a7ee0a..9d1d5322fb16833d77b4df44a6d5675517906d8e 100644 |
--- a/webrtc/modules/audio_device/win/audio_device_core_win.cc |
+++ b/webrtc/modules/audio_device/win/audio_device_core_win.cc |
@@ -406,8 +406,6 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() |
AudioDeviceWindowsCore::AudioDeviceWindowsCore(const int32_t id) : |
_comInit(ScopedCOMInitializer::kMTA), |
- _critSect(*CriticalSectionWrapper::CreateCriticalSection()), |
- _volumeMutex(*CriticalSectionWrapper::CreateCriticalSection()), |
_id(id), |
_ptrAudioBuffer(NULL), |
_ptrEnumerator(NULL), |
@@ -638,9 +636,6 @@ AudioDeviceWindowsCore::~AudioDeviceWindowsCore() |
"AudioDeviceWindowsCore::~AudioDeviceWindowsCore() the Avrt DLL module is now unloaded"); |
} |
} |
- |
- delete &_critSect; |
- delete &_volumeMutex; |
} |
// ============================================================================ |
@@ -680,7 +675,7 @@ int32_t AudioDeviceWindowsCore::ActiveAudioLayer(AudioDeviceModule::AudioLayer& |
// ---------------------------------------------------------------------------- |
AudioDeviceGeneric::InitStatus AudioDeviceWindowsCore::Init() { |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_initialized) { |
return InitStatus::OK; |
@@ -709,7 +704,7 @@ AudioDeviceGeneric::InitStatus AudioDeviceWindowsCore::Init() { |
int32_t AudioDeviceWindowsCore::Terminate() |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (!_initialized) { |
return 0; |
@@ -751,7 +746,7 @@ bool AudioDeviceWindowsCore::Initialized() const |
int32_t AudioDeviceWindowsCore::InitSpeaker() |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_playing) |
{ |
@@ -833,7 +828,7 @@ int32_t AudioDeviceWindowsCore::InitSpeaker() |
int32_t AudioDeviceWindowsCore::InitMicrophone() |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_recording) |
{ |
@@ -923,7 +918,7 @@ bool AudioDeviceWindowsCore::MicrophoneIsInitialized() const |
int32_t AudioDeviceWindowsCore::SpeakerVolumeIsAvailable(bool& available) |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_ptrDeviceOut == NULL) |
{ |
@@ -968,7 +963,7 @@ int32_t AudioDeviceWindowsCore::SetSpeakerVolume(uint32_t volume) |
{ |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (!_speakerIsInitialized) |
{ |
@@ -1011,7 +1006,7 @@ int32_t AudioDeviceWindowsCore::SpeakerVolume(uint32_t& volume) const |
{ |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (!_speakerIsInitialized) |
{ |
@@ -1123,7 +1118,7 @@ int32_t AudioDeviceWindowsCore::SpeakerVolumeStepSize(uint16_t& stepSize) const |
int32_t AudioDeviceWindowsCore::SpeakerMuteIsAvailable(bool& available) |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_ptrDeviceOut == NULL) |
{ |
@@ -1162,7 +1157,7 @@ Exit: |
int32_t AudioDeviceWindowsCore::SetSpeakerMute(bool enable) |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (!_speakerIsInitialized) |
{ |
@@ -1242,7 +1237,7 @@ Exit: |
int32_t AudioDeviceWindowsCore::MicrophoneMuteIsAvailable(bool& available) |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_ptrDeviceIn == NULL) |
{ |
@@ -1402,7 +1397,7 @@ int32_t AudioDeviceWindowsCore::StereoRecordingIsAvailable(bool& available) |
int32_t AudioDeviceWindowsCore::SetStereoRecording(bool enable) |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (enable) |
{ |
@@ -1453,7 +1448,7 @@ int32_t AudioDeviceWindowsCore::StereoPlayoutIsAvailable(bool& available) |
int32_t AudioDeviceWindowsCore::SetStereoPlayout(bool enable) |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (enable) |
{ |
@@ -1492,7 +1487,7 @@ int32_t AudioDeviceWindowsCore::StereoPlayout(bool& enabled) const |
int32_t AudioDeviceWindowsCore::SetAGC(bool enable) |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
_AGC = enable; |
return 0; |
} |
@@ -1503,7 +1498,7 @@ int32_t AudioDeviceWindowsCore::SetAGC(bool enable) |
bool AudioDeviceWindowsCore::AGC() const |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
return _AGC; |
} |
@@ -1514,7 +1509,7 @@ bool AudioDeviceWindowsCore::AGC() const |
int32_t AudioDeviceWindowsCore::MicrophoneVolumeIsAvailable(bool& available) |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_ptrDeviceIn == NULL) |
{ |
@@ -1553,7 +1548,7 @@ int32_t AudioDeviceWindowsCore::SetMicrophoneVolume(uint32_t volume) |
WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, "AudioDeviceWindowsCore::SetMicrophoneVolume(volume=%u)", volume); |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (!_microphoneIsInitialized) |
{ |
@@ -1594,7 +1589,7 @@ Exit: |
int32_t AudioDeviceWindowsCore::MicrophoneVolume(uint32_t& volume) const |
{ |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (!_microphoneIsInitialized) |
{ |
@@ -1689,7 +1684,7 @@ int32_t AudioDeviceWindowsCore::MicrophoneVolumeStepSize(uint16_t& stepSize) con |
int16_t AudioDeviceWindowsCore::PlayoutDevices() |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_RefreshDeviceList(eRender) != -1) |
{ |
@@ -1720,7 +1715,7 @@ int32_t AudioDeviceWindowsCore::SetPlayoutDevice(uint16_t index) |
return -1; |
} |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
HRESULT hr(S_OK); |
@@ -1775,7 +1770,7 @@ int32_t AudioDeviceWindowsCore::SetPlayoutDevice(AudioDeviceModule::WindowsDevic |
role = eCommunications; |
} |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
// Refresh the list of rendering endpoint devices |
_RefreshDeviceList(eRender); |
@@ -1845,7 +1840,7 @@ int32_t AudioDeviceWindowsCore::PlayoutDeviceName( |
memset(guid, 0, kAdmMaxGuidSize); |
} |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
int32_t ret(-1); |
WCHAR szDeviceName[MAX_PATH]; |
@@ -1925,7 +1920,7 @@ int32_t AudioDeviceWindowsCore::RecordingDeviceName( |
memset(guid, 0, kAdmMaxGuidSize); |
} |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
int32_t ret(-1); |
WCHAR szDeviceName[MAX_PATH]; |
@@ -1979,7 +1974,7 @@ int32_t AudioDeviceWindowsCore::RecordingDeviceName( |
int16_t AudioDeviceWindowsCore::RecordingDevices() |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_RefreshDeviceList(eCapture) != -1) |
{ |
@@ -2010,7 +2005,7 @@ int32_t AudioDeviceWindowsCore::SetRecordingDevice(uint16_t index) |
return -1; |
} |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
HRESULT hr(S_OK); |
@@ -2065,7 +2060,7 @@ int32_t AudioDeviceWindowsCore::SetRecordingDevice(AudioDeviceModule::WindowsDev |
role = eCommunications; |
} |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
// Refresh the list of capture endpoint devices |
_RefreshDeviceList(eCapture); |
@@ -2155,7 +2150,7 @@ int32_t AudioDeviceWindowsCore::RecordingIsAvailable(bool& available) |
int32_t AudioDeviceWindowsCore::InitPlayout() |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_playing) |
{ |
@@ -2495,7 +2490,7 @@ int32_t AudioDeviceWindowsCore::InitRecordingDMO() |
int32_t AudioDeviceWindowsCore::InitRecording() |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
if (_recording) |
{ |
@@ -2746,7 +2741,7 @@ int32_t AudioDeviceWindowsCore::StartRecording() |
} |
{ |
- CriticalSectionScoped critScoped(&_critSect); |
+ rtc::CritScope critScoped(&_critSect); |
// Create thread which will drive the capturing |
LPTHREAD_START_ROUTINE lpStartAddress = WSAPICaptureThread; |
@@ -2996,7 +2991,7 @@ int32_t AudioDeviceWindowsCore::StartPlayout() |
} |
{ |
- CriticalSectionScoped critScoped(&_critSect); |
+ rtc::CritScope critScoped(&_critSect); |
// Create thread which will drive the rendering. |
assert(_hPlayThread == NULL); |
@@ -3046,7 +3041,7 @@ int32_t AudioDeviceWindowsCore::StopPlayout() |
} |
{ |
- CriticalSectionScoped critScoped(&_critSect) ; |
+ rtc::CritScope critScoped(&_critSect) ; |
if (_hPlayThread == NULL) |
{ |
@@ -3079,7 +3074,7 @@ int32_t AudioDeviceWindowsCore::StopPlayout() |
} |
{ |
- CriticalSectionScoped critScoped(&_critSect); |
+ rtc::CritScope critScoped(&_critSect); |
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
"webrtc_core_audio_render_thread is now closed"); |
@@ -3123,7 +3118,7 @@ int32_t AudioDeviceWindowsCore::StopPlayout() |
int32_t AudioDeviceWindowsCore::PlayoutDelay(uint16_t& delayMS) const |
{ |
- CriticalSectionScoped critScoped(&_critSect); |
+ rtc::CritScope critScoped(&_critSect); |
delayMS = static_cast<uint16_t>(_sndCardPlayDelay); |
return 0; |
} |
@@ -3134,7 +3129,7 @@ int32_t AudioDeviceWindowsCore::PlayoutDelay(uint16_t& delayMS) const |
int32_t AudioDeviceWindowsCore::RecordingDelay(uint16_t& delayMS) const |
{ |
- CriticalSectionScoped critScoped(&_critSect); |
+ rtc::CritScope critScoped(&_critSect); |
delayMS = static_cast<uint16_t>(_sndCardRecDelay); |
return 0; |
} |
@@ -3154,7 +3149,7 @@ bool AudioDeviceWindowsCore::Playing() const |
int32_t AudioDeviceWindowsCore::SetPlayoutBuffer(const AudioDeviceModule::BufferType type, uint16_t sizeMS) |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
_playBufType = type; |
@@ -3172,7 +3167,7 @@ int32_t AudioDeviceWindowsCore::SetPlayoutBuffer(const AudioDeviceModule::Buffer |
int32_t AudioDeviceWindowsCore::PlayoutBuffer(AudioDeviceModule::BufferType& type, uint16_t& sizeMS) const |
{ |
- CriticalSectionScoped lock(&_critSect); |
+ rtc::CritScope lock(&_critSect); |
type = _playBufType; |
if (type == AudioDeviceModule::kFixedBufferSize) |
@@ -3773,7 +3768,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() |
while (keepRecording) |
{ |
- CriticalSectionScoped critScoped(&_critSect); |
+ rtc::CritScope critScoped(&_critSect); |
DWORD dwStatus = 0; |
{ |