From b0550bdf96c9c7db8f635fed4fe374f1f316a76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Thu, 8 Nov 2018 16:05:31 +0100 Subject: [PATCH] Eliminate use of EventWrapper from mac audio device Bug: webrtc:3380 Change-Id: I9b34588a6a2b035f1787782421e4fc3e6650ef1a Reviewed-on: https://webrtc-review.googlesource.com/c/110244 Reviewed-by: Henrik Andreassson Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#25567} --- modules/audio_device/mac/audio_device_mac.cc | 14 +++----------- modules/audio_device/mac/audio_device_mac.h | 7 +++---- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/modules/audio_device/mac/audio_device_mac.cc b/modules/audio_device/mac/audio_device_mac.cc index 063ac85736..9daf7bddf7 100644 --- a/modules/audio_device/mac/audio_device_mac.cc +++ b/modules/audio_device/mac/audio_device_mac.cc @@ -16,7 +16,6 @@ #include "rtc_base/checks.h" #include "rtc_base/platform_thread.h" #include "rtc_base/system/arch.h" -#include "system_wrappers/include/event_wrapper.h" #include #include // OSAtomicCompareAndSwap() @@ -115,8 +114,6 @@ void AudioDeviceMac::logCAMsg(const rtc::LoggingSeverity sev, AudioDeviceMac::AudioDeviceMac() : _ptrAudioBuffer(NULL), - _stopEventRec(*EventWrapper::Create()), - _stopEvent(*EventWrapper::Create()), _mixerManager(), _inputDeviceIndex(0), _outputDeviceIndex(0), @@ -153,9 +150,6 @@ AudioDeviceMac::AudioDeviceMac() prev_key_state_() { RTC_LOG(LS_INFO) << __FUNCTION__ << " created"; - RTC_DCHECK(&_stopEvent != NULL); - RTC_DCHECK(&_stopEventRec != NULL); - memset(_renderConvertData, 0, sizeof(_renderConvertData)); memset(&_outStreamFormat, 0, sizeof(AudioStreamBasicDescription)); memset(&_outDesiredFormat, 0, sizeof(AudioStreamBasicDescription)); @@ -204,8 +198,6 @@ AudioDeviceMac::~AudioDeviceMac() { RTC_LOG(LS_ERROR) << "semaphore_destroy() error: " << kernErr; } - delete &_stopEvent; - delete &_stopEventRec; } // ============================================================================ @@ -1338,7 +1330,7 @@ int32_t AudioDeviceMac::StopRecording() { _recording = false; _doStopRec = true; // Signal to io proc to stop audio device _critSect.Leave(); // Cannot be under lock, risk of deadlock - if (kEventTimeout == _stopEventRec.Wait(2000)) { + if (!_stopEventRec.Wait(2000)) { rtc::CritScope critScoped(&_critSect); RTC_LOG(LS_WARNING) << "Timed out stopping the capture IOProc." << "We may have failed to detect a device removal."; @@ -1366,7 +1358,7 @@ int32_t AudioDeviceMac::StopRecording() { _recording = false; _doStop = true; // Signal to io proc to stop audio device _critSect.Leave(); // Cannot be under lock, risk of deadlock - if (kEventTimeout == _stopEvent.Wait(2000)) { + if (!_stopEvent.Wait(2000)) { rtc::CritScope critScoped(&_critSect); RTC_LOG(LS_WARNING) << "Timed out stopping the shared IOProc." << "We may have failed to detect a device removal."; @@ -1474,7 +1466,7 @@ int32_t AudioDeviceMac::StopPlayout() { _playing = false; _doStop = true; // Signal to io proc to stop audio device _critSect.Leave(); // Cannot be under lock, risk of deadlock - if (kEventTimeout == _stopEvent.Wait(2000)) { + if (!_stopEvent.Wait(2000)) { rtc::CritScope critScoped(&_critSect); RTC_LOG(LS_WARNING) << "Timed out stopping the render IOProc." << "We may have failed to detect a device removal."; diff --git a/modules/audio_device/mac/audio_device_mac.h b/modules/audio_device/mac/audio_device_mac.h index 5cbdae2837..5a70760653 100644 --- a/modules/audio_device/mac/audio_device_mac.h +++ b/modules/audio_device/mac/audio_device_mac.h @@ -16,9 +16,9 @@ #include "modules/audio_device/audio_device_generic.h" #include "modules/audio_device/mac/audio_mixer_manager_mac.h" #include "rtc_base/criticalsection.h" +#include "rtc_base/event.h" #include "rtc_base/logging.h" #include "rtc_base/thread_annotations.h" -#include "system_wrappers/include/event_wrapper.h" #include #include @@ -31,7 +31,6 @@ class PlatformThread; } // namespace rtc namespace webrtc { -class EventWrapper; const uint32_t N_REC_SAMPLES_PER_SEC = 48000; const uint32_t N_PLAY_SAMPLES_PER_SEC = 48000; @@ -252,8 +251,8 @@ class AudioDeviceMac : public AudioDeviceGeneric { rtc::CriticalSection _critSect; - EventWrapper& _stopEventRec; - EventWrapper& _stopEvent; + rtc::Event _stopEventRec; + rtc::Event _stopEvent; // TODO(pbos): Replace with direct members, just start/stop, no need to // recreate the thread.