From b4aa4eb06f745ea48ae891e8d1dd970beca500ba Mon Sep 17 00:00:00 2001 From: saza Date: Wed, 19 Jul 2017 01:12:36 -0700 Subject: [PATCH] Replace WEBRTC_TRACE logging in modules/audio_device/.. mac/ win/ Patch set 1: Run a script to replace occurrences of WEBRTC_TRACE logging with the new style, on webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc. Patch set 2: - Manually fix log lines not handled by the script - Adjust local macros that use WEBRTC_TRACE - Adjust some lines to conform with code style - Update the included headers - Remove the now unused object ID variables BUG=webrtc:5118 Review-Url: https://codereview.webrtc.org/2985443002 Cr-Commit-Position: refs/heads/master@{#19088} --- .../modules/audio_device/audio_device_impl.cc | 4 +- .../audio_device/mac/audio_device_mac.cc | 410 +++++------- .../audio_device/mac/audio_device_mac.h | 9 +- .../mac/audio_mixer_manager_mac.cc | 244 +++---- .../mac/audio_mixer_manager_mac.h | 9 +- .../audio_device/win/audio_device_core_win.cc | 606 +++++++++--------- .../audio_device/win/audio_device_core_win.h | 5 +- 7 files changed, 603 insertions(+), 684 deletions(-) diff --git a/webrtc/modules/audio_device/audio_device_impl.cc b/webrtc/modules/audio_device/audio_device_impl.cc index 58d58d3d03..d7ab4092ee 100644 --- a/webrtc/modules/audio_device/audio_device_impl.cc +++ b/webrtc/modules/audio_device/audio_device_impl.cc @@ -201,7 +201,7 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() { if (AudioDeviceWindowsCore::CoreAudioIsSupported()) { // create *Windows Core Audio* implementation - ptrAudioDevice = new AudioDeviceWindowsCore(Id()); + ptrAudioDevice = new AudioDeviceWindowsCore(); LOG(INFO) << "Windows Core Audio APIs will be utilized"; } } @@ -302,7 +302,7 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() { #elif defined(WEBRTC_MAC) if (audioLayer == kPlatformDefaultAudio) { // Create *Mac Audio* implementation - ptrAudioDevice = new AudioDeviceMac(Id()); + ptrAudioDevice = new AudioDeviceMac(); LOG(INFO) << "Mac OS X Audio APIs will be utilized"; } #endif // WEBRTC_MAC diff --git a/webrtc/modules/audio_device/mac/audio_device_mac.cc b/webrtc/modules/audio_device/mac/audio_device_mac.cc index e40d23c725..59906a8745 100644 --- a/webrtc/modules/audio_device/mac/audio_device_mac.cc +++ b/webrtc/modules/audio_device/mac/audio_device_mac.cc @@ -13,10 +13,8 @@ #include "webrtc/modules/audio_device/mac/portaudio/pa_ringbuffer.h" #include "webrtc/rtc_base/arraysize.h" #include "webrtc/rtc_base/checks.h" -#include "webrtc/rtc_base/logging.h" #include "webrtc/rtc_base/platform_thread.h" #include "webrtc/system_wrappers/include/event_wrapper.h" -#include "webrtc/system_wrappers/include/trace.h" #include #include // OSAtomicCompareAndSwap() @@ -29,7 +27,7 @@ namespace webrtc { do { \ err = expr; \ if (err != noErr) { \ - logCAMsg(kTraceError, kTraceAudioDevice, _id, "Error in " #expr, \ + logCAMsg(rtc::LS_ERROR, "Error in " #expr, \ (const char*) & err); \ return -1; \ } \ @@ -39,7 +37,7 @@ namespace webrtc { do { \ err = expr; \ if (err != noErr) { \ - logCAMsg(kTraceError, kTraceAudioDevice, _id, "Error in " #expr, \ + logCAMsg(rtc::LS_ERROR, "Error in " #expr, \ (const char*) & err); \ } \ } while (0) @@ -48,7 +46,7 @@ namespace webrtc { do { \ err = expr; \ if (err != noErr) { \ - logCAMsg(kTraceWarning, kTraceAudioDevice, _id, "Error in " #expr, \ + logCAMsg(rtc::LS_WARNING, "Error in " #expr, \ (const char*) & err); \ } \ } while (0) @@ -74,29 +72,49 @@ int32_t AudioDeviceMac::AtomicGet32(int32_t* theValue) { } // CoreAudio errors are best interpreted as four character strings. -void AudioDeviceMac::logCAMsg(const TraceLevel level, - const TraceModule module, - const int32_t id, +void AudioDeviceMac::logCAMsg(const rtc::LoggingSeverity sev, const char* msg, const char* err) { RTC_DCHECK(msg != NULL); RTC_DCHECK(err != NULL); #ifdef WEBRTC_ARCH_BIG_ENDIAN - WEBRTC_TRACE(level, module, id, "%s: %.4s", msg, err); + switch (sev) { + case rtc::LS_ERROR: + LOG(LS_ERROR) << msg << ": " << err[0] << err[1] << err[2] << err[3]; + break; + case rtc::LS_WARNING: + LOG(LS_WARNING) << msg << ": " << err[0] << err[1] << err[2] << err[3]; + break; + case rtc::LS_VERBOSE: + LOG(LS_VERBOSE) << msg << ": " << err[0] << err[1] << err[2] << err[3]; + break; + default: + break; + } #else // We need to flip the characters in this case. - WEBRTC_TRACE(level, module, id, "%s: %.1s%.1s%.1s%.1s", msg, err + 3, err + 2, - err + 1, err); + switch (sev) { + case rtc::LS_ERROR: + LOG(LS_ERROR) << msg << ": " << err[3] << err[2] << err[1] << err[0]; + break; + case rtc::LS_WARNING: + LOG(LS_WARNING) << msg << ": " << err[3] << err[2] << err[1] << err[0]; + break; + case rtc::LS_VERBOSE: + LOG(LS_VERBOSE) << msg << ": " << err[3] << err[2] << err[1] << err[0]; + break; + default: + break; + } #endif } -AudioDeviceMac::AudioDeviceMac(const int32_t id) +AudioDeviceMac::AudioDeviceMac() : _ptrAudioBuffer(NULL), _stopEventRec(*EventWrapper::Create()), _stopEvent(*EventWrapper::Create()), - _id(id), - _mixerManager(id), + _mixerManager(), _inputDeviceIndex(0), _outputDeviceIndex(0), _inputDeviceID(kAudioObjectUnknown), @@ -138,7 +156,7 @@ AudioDeviceMac::AudioDeviceMac(const int32_t id) _renderBufSizeSamples(0), prev_key_state_(), get_mic_volume_counter_ms_(0) { - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, "%s created", __FUNCTION__); + LOG(LS_INFO) << __FUNCTION__ << " created"; RTC_DCHECK(&_stopEvent != NULL); RTC_DCHECK(&_stopEventRec != NULL); @@ -151,8 +169,7 @@ AudioDeviceMac::AudioDeviceMac(const int32_t id) } AudioDeviceMac::~AudioDeviceMac() { - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s destroyed", - __FUNCTION__); + LOG(LS_INFO) << __FUNCTION__ << " destroyed"; if (!_isShutDown) { Terminate(); @@ -184,14 +201,12 @@ AudioDeviceMac::~AudioDeviceMac() { kern_return_t kernErr = KERN_SUCCESS; kernErr = semaphore_destroy(mach_task_self(), _renderSemaphore); if (kernErr != KERN_SUCCESS) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " semaphore_destroy() error: %d", kernErr); + LOG(LS_ERROR) << "semaphore_destroy() error: " << kernErr; } kernErr = semaphore_destroy(mach_task_self(), _captureSemaphore); if (kernErr != KERN_SUCCESS) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " semaphore_destroy() error: %d", kernErr); + LOG(LS_ERROR) << "semaphore_destroy() error: " << kernErr; } delete &_stopEvent; @@ -247,8 +262,7 @@ AudioDeviceGeneric::InitStatus AudioDeviceMac::Init() { bufSize = PaUtil_InitializeRingBuffer( _paRenderBuffer, sizeof(SInt16), _renderBufSizeSamples, _renderBufData); if (bufSize == -1) { - WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, - " PaUtil_InitializeRingBuffer() error"); + LOG(LS_ERROR) << "PaUtil_InitializeRingBuffer() error"; return InitStatus::PLAYOUT_ERROR; } } @@ -269,8 +283,7 @@ AudioDeviceGeneric::InitStatus AudioDeviceMac::Init() { PaUtil_InitializeRingBuffer(_paCaptureBuffer, sizeof(Float32), _captureBufSizeSamples, _captureBufData); if (bufSize == -1) { - WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, - " PaUtil_InitializeRingBuffer() error"); + LOG(LS_ERROR) << "PaUtil_InitializeRingBuffer() error"; return InitStatus::RECORDING_ERROR; } } @@ -279,16 +292,14 @@ AudioDeviceGeneric::InitStatus AudioDeviceMac::Init() { kernErr = semaphore_create(mach_task_self(), &_renderSemaphore, SYNC_POLICY_FIFO, 0); if (kernErr != KERN_SUCCESS) { - WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, - " semaphore_create() error: %d", kernErr); + LOG(LS_ERROR) << "semaphore_create() error: " << kernErr; return InitStatus::OTHER_ERROR; } kernErr = semaphore_create(mach_task_self(), &_captureSemaphore, SYNC_POLICY_FIFO, 0); if (kernErr != KERN_SUCCESS) { - WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, - " semaphore_create() error: %d", kernErr); + LOG(LS_ERROR) << "semaphore_create() error: " << kernErr; return InitStatus::OTHER_ERROR; } @@ -323,11 +334,9 @@ AudioDeviceGeneric::InitStatus AudioDeviceMac::Init() { int intErr = sysctlbyname("hw.model", buf, &length, NULL, 0); if (intErr != 0) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " Error in sysctlbyname(): %d", err); + LOG(LS_ERROR) << "Error in sysctlbyname(): " << err; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, " Hardware model: %s", - buf); + LOG(LS_VERBOSE) << "Hardware model: " << buf; if (strncmp(buf, "MacBookPro", 10) == 0) { _macBookPro = true; } @@ -351,14 +360,12 @@ int32_t AudioDeviceMac::Terminate() { } if (_recording) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " Recording must be stopped"); + LOG(LS_ERROR) << "Recording must be stopped"; return -1; } if (_playing) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " Playback must be stopped"); + LOG(LS_ERROR) << "Playback must be stopped"; return -1; } @@ -377,7 +384,7 @@ int32_t AudioDeviceMac::Terminate() { err = AudioHardwareUnload(); if (err != noErr) { - logCAMsg(kTraceError, kTraceAudioDevice, _id, + logCAMsg(rtc::LS_ERROR, "Error in AudioHardwareUnload()", (const char*)&err); retVal = -1; } @@ -543,15 +550,13 @@ int32_t AudioDeviceMac::SpeakerVolume(uint32_t& volume) const { int32_t AudioDeviceMac::SetWaveOutVolume(uint16_t volumeLeft, uint16_t volumeRight) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " API call not supported on this platform"); + LOG(LS_WARNING) << "API call not supported on this platform"; return -1; } int32_t AudioDeviceMac::WaveOutVolume(uint16_t& /*volumeLeft*/, uint16_t& /*volumeRight*/) const { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " API call not supported on this platform"); + LOG(LS_WARNING) << "API call not supported on this platform"; return -1; } @@ -850,8 +855,7 @@ int32_t AudioDeviceMac::MicrophoneVolume(uint32_t& volume) const { uint32_t level(0); if (_mixerManager.MicrophoneVolume(level) == -1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " failed to retrive current microphone level"); + LOG(LS_WARNING) << "failed to retrieve current microphone level"; return -1; } @@ -908,13 +912,12 @@ int32_t AudioDeviceMac::SetPlayoutDevice(uint16_t index) { AudioDeviceID playDevices[MaxNumberDevices]; uint32_t nDevices = GetNumberDevices(kAudioDevicePropertyScopeOutput, playDevices, MaxNumberDevices); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " number of availiable waveform-audio output devices is %u", - nDevices); + LOG(LS_VERBOSE) << "number of available waveform-audio output devices is " + << nDevices; if (index > (nDevices - 1)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " device index is out of range [0,%u]", (nDevices - 1)); + LOG(LS_ERROR) << "device index is out of range [0," << (nDevices - 1) + << "]"; return -1; } @@ -926,8 +929,7 @@ int32_t AudioDeviceMac::SetPlayoutDevice(uint16_t index) { int32_t AudioDeviceMac::SetPlayoutDevice( AudioDeviceModule::WindowsDeviceType /*device*/) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "WindowsDeviceType not supported"); + LOG(LS_ERROR) << "WindowsDeviceType not supported"; return -1; } @@ -981,13 +983,12 @@ int32_t AudioDeviceMac::SetRecordingDevice(uint16_t index) { AudioDeviceID recDevices[MaxNumberDevices]; uint32_t nDevices = GetNumberDevices(kAudioDevicePropertyScopeInput, recDevices, MaxNumberDevices); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " number of availiable waveform-audio input devices is %u", - nDevices); + LOG(LS_VERBOSE) << "number of available waveform-audio input devices is " + << nDevices; if (index > (nDevices - 1)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " device index is out of range [0,%u]", (nDevices - 1)); + LOG(LS_ERROR) << "device index is out of range [0," << (nDevices - 1) + << "]"; return -1; } @@ -999,8 +1000,7 @@ int32_t AudioDeviceMac::SetRecordingDevice(uint16_t index) { int32_t AudioDeviceMac::SetRecordingDevice( AudioDeviceModule::WindowsDeviceType /*device*/) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "WindowsDeviceType not supported"); + LOG(LS_ERROR) << "WindowsDeviceType not supported"; return -1; } @@ -1067,8 +1067,7 @@ int32_t AudioDeviceMac::InitPlayout() { // Initialize the speaker (devices might have been added or removed) if (InitSpeaker() == -1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " InitSpeaker() failed"); + LOG(LS_WARNING) << "InitSpeaker() failed"; } if (!MicrophoneIsInitialized()) { @@ -1076,8 +1075,7 @@ int32_t AudioDeviceMac::InitPlayout() { // one or two devices (_twoDevices) bool available = false; if (MicrophoneIsAvailable(available) == -1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " MicrophoneIsAvailable() failed"); + LOG(LS_WARNING) << "MicrophoneIsAvailable() failed"; } } @@ -1108,12 +1106,10 @@ int32_t AudioDeviceMac::InitPlayout() { if (dataSource == 'ispk') { _macBookProPanRight = true; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "MacBook Pro using internal speakers; stereo" - " panning right"); + LOG(LS_VERBOSE) + << "MacBook Pro using internal speakers; stereo panning right"; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "MacBook Pro not using internal speakers"); + LOG(LS_VERBOSE) << "MacBook Pro not using internal speakers"; } // Add a listener to determine if the status changes. @@ -1130,50 +1126,42 @@ int32_t AudioDeviceMac::InitPlayout() { _outputDeviceID, &propertyAddress, 0, NULL, &size, &_outStreamFormat)); if (_outStreamFormat.mFormatID != kAudioFormatLinearPCM) { - logCAMsg(kTraceError, kTraceAudioDevice, _id, + logCAMsg(rtc::LS_ERROR, "Unacceptable output stream format -> mFormatID", (const char*)&_outStreamFormat.mFormatID); return -1; } if (_outStreamFormat.mChannelsPerFrame > N_DEVICE_CHANNELS) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Too many channels on output device (mChannelsPerFrame = %d)", - _outStreamFormat.mChannelsPerFrame); + LOG(LS_ERROR) << "Too many channels on output device (mChannelsPerFrame = " + << _outStreamFormat.mChannelsPerFrame << ")"; return -1; } if (_outStreamFormat.mFormatFlags & kAudioFormatFlagIsNonInterleaved) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Non-interleaved audio data is not supported.", - "AudioHardware streams should not have this format."); + LOG(LS_ERROR) << "Non-interleaved audio data is not supported." + << "AudioHardware streams should not have this format."; return -1; } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Ouput stream format:"); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "mSampleRate = %f, mChannelsPerFrame = %u", - _outStreamFormat.mSampleRate, - _outStreamFormat.mChannelsPerFrame); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "mBytesPerPacket = %u, mFramesPerPacket = %u", - _outStreamFormat.mBytesPerPacket, - _outStreamFormat.mFramesPerPacket); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "mBytesPerFrame = %u, mBitsPerChannel = %u", - _outStreamFormat.mBytesPerFrame, - _outStreamFormat.mBitsPerChannel); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "mFormatFlags = %u", - _outStreamFormat.mFormatFlags); - logCAMsg(kTraceInfo, kTraceAudioDevice, _id, "mFormatID", + LOG(LS_VERBOSE) << "Ouput stream format:"; + LOG(LS_VERBOSE) << "mSampleRate = " << _outStreamFormat.mSampleRate + << ", mChannelsPerFrame = " + << _outStreamFormat.mChannelsPerFrame; + LOG(LS_VERBOSE) << "mBytesPerPacket = " << _outStreamFormat.mBytesPerPacket + << ", mFramesPerPacket = " + << _outStreamFormat.mFramesPerPacket; + LOG(LS_VERBOSE) << "mBytesPerFrame = " << _outStreamFormat.mBytesPerFrame + << ", mBitsPerChannel = " << _outStreamFormat.mBitsPerChannel; + LOG(LS_VERBOSE) << "mFormatFlags = " << _outStreamFormat.mFormatFlags; + logCAMsg(rtc::LS_VERBOSE, "mFormatID", (const char*)&_outStreamFormat.mFormatID); // Our preferred format to work with. if (_outStreamFormat.mChannelsPerFrame < 2) { // Disable stereo playout when we only have one channel on the device. _playChannels = 1; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "Stereo playout unavailable on this device"); + LOG(LS_VERBOSE) << "Stereo playout unavailable on this device"; } WEBRTC_CA_RETURN_ON_ERR(SetDesiredPlayoutFormat()); @@ -1214,8 +1202,7 @@ int32_t AudioDeviceMac::InitRecording() { // Initialize the microphone (devices might have been added or removed) if (InitMicrophone() == -1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " InitMicrophone() failed"); + LOG(LS_WARNING) << "InitMicrophone() failed"; } if (!SpeakerIsInitialized()) { @@ -1223,8 +1210,7 @@ int32_t AudioDeviceMac::InitRecording() { // one or two devices (_twoDevices) bool available = false; if (SpeakerIsAvailable(available) == -1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " SpeakerIsAvailable() failed"); + LOG(LS_WARNING) << "SpeakerIsAvailable() failed"; } } @@ -1247,16 +1233,15 @@ int32_t AudioDeviceMac::InitRecording() { _inputDeviceID, &propertyAddress, 0, NULL, &size, &_inStreamFormat)); if (_inStreamFormat.mFormatID != kAudioFormatLinearPCM) { - logCAMsg(kTraceError, kTraceAudioDevice, _id, + logCAMsg(rtc::LS_ERROR, "Unacceptable input stream format -> mFormatID", (const char*)&_inStreamFormat.mFormatID); return -1; } if (_inStreamFormat.mChannelsPerFrame > N_DEVICE_CHANNELS) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Too many channels on input device (mChannelsPerFrame = %d)", - _inStreamFormat.mChannelsPerFrame); + LOG(LS_ERROR) << "Too many channels on input device (mChannelsPerFrame = " + << _inStreamFormat.mChannelsPerFrame << ")"; return -1; } @@ -1264,26 +1249,23 @@ int32_t AudioDeviceMac::InitRecording() { _inStreamFormat.mSampleRate / 100 * N_BLOCKS_IO; if (io_block_size_samples > _captureBufSizeSamples) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Input IO block size (%d) is larger than ring buffer (%u)", - io_block_size_samples, _captureBufSizeSamples); + LOG(LS_ERROR) << "Input IO block size (" << io_block_size_samples + << ") is larger than ring buffer (" << _captureBufSizeSamples + << ")"; return -1; } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, " Input stream format:"); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " mSampleRate = %f, mChannelsPerFrame = %u", - _inStreamFormat.mSampleRate, _inStreamFormat.mChannelsPerFrame); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " mBytesPerPacket = %u, mFramesPerPacket = %u", - _inStreamFormat.mBytesPerPacket, - _inStreamFormat.mFramesPerPacket); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " mBytesPerFrame = %u, mBitsPerChannel = %u", - _inStreamFormat.mBytesPerFrame, _inStreamFormat.mBitsPerChannel); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, " mFormatFlags = %u", - _inStreamFormat.mFormatFlags); - logCAMsg(kTraceInfo, kTraceAudioDevice, _id, "mFormatID", + LOG(LS_VERBOSE) << "Input stream format:"; + LOG(LS_VERBOSE) << "mSampleRate = " << _inStreamFormat.mSampleRate + << ", mChannelsPerFrame = " + << _inStreamFormat.mChannelsPerFrame; + LOG(LS_VERBOSE) << "mBytesPerPacket = " << _inStreamFormat.mBytesPerPacket + << ", mFramesPerPacket = " + << _inStreamFormat.mFramesPerPacket; + LOG(LS_VERBOSE) << "mBytesPerFrame = " << _inStreamFormat.mBytesPerFrame + << ", mBitsPerChannel = " << _inStreamFormat.mBitsPerChannel; + LOG(LS_VERBOSE) << "mFormatFlags = " << _inStreamFormat.mFormatFlags; + logCAMsg(rtc::LS_VERBOSE, "mFormatID", (const char*)&_inStreamFormat.mFormatID); // Our preferred format to work with @@ -1293,8 +1275,7 @@ int32_t AudioDeviceMac::InitRecording() { // Disable stereo recording when we only have one channel on the device. _inDesiredFormat.mChannelsPerFrame = 1; _recChannels = 1; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "Stereo recording unavailable on this device"); + LOG(LS_VERBOSE) << "Stereo recording unavailable on this device"; } if (_ptrAudioBuffer) { @@ -1411,8 +1392,7 @@ int32_t AudioDeviceMac::StartRecording() { } if (!_initialized) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " Recording worker thread has not been started"); + LOG(LS_ERROR) << "Recording worker thread has not been started"; return -1; } @@ -1454,9 +1434,9 @@ int32_t AudioDeviceMac::StopRecording() { _critSect.Leave(); // Cannot be under lock, risk of deadlock if (kEventTimeout == _stopEventRec.Wait(2000)) { rtc::CritScope critScoped(&_critSect); - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Timed out stopping the capture IOProc. " - "We may have failed to detect a device removal."); + LOG(LS_WARNING) + << "Timed out stopping the capture IOProc." + << "We may have failed to detect a device removal."; WEBRTC_CA_LOG_WARN(AudioDeviceStop(_inputDeviceID, _inDeviceIOProcID)); WEBRTC_CA_LOG_WARN( @@ -1464,7 +1444,7 @@ int32_t AudioDeviceMac::StopRecording() { } _critSect.Enter(); _doStopRec = false; - WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id, " Recording stopped"); + LOG(LS_VERBOSE) << "Recording stopped"; } } else { // We signal a stop for a shared device even when rendering has @@ -1480,9 +1460,9 @@ int32_t AudioDeviceMac::StopRecording() { _critSect.Leave(); // Cannot be under lock, risk of deadlock if (kEventTimeout == _stopEvent.Wait(2000)) { rtc::CritScope critScoped(&_critSect); - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Timed out stopping the shared IOProc. " - "We may have failed to detect a device removal."); + LOG(LS_WARNING) + << "Timed out stopping the shared IOProc." + << "We may have failed to detect a device removal."; // We assume rendering on a shared device has stopped as well if // the IOProc times out. @@ -1492,8 +1472,7 @@ int32_t AudioDeviceMac::StopRecording() { } _critSect.Enter(); _doStop = false; - WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id, - " Recording stopped (shared)"); + LOG(LS_VERBOSE) << "Recording stopped (shared)"; } } @@ -1586,9 +1565,9 @@ int32_t AudioDeviceMac::StopPlayout() { _critSect.Leave(); // Cannot be under lock, risk of deadlock if (kEventTimeout == _stopEvent.Wait(2000)) { rtc::CritScope critScoped(&_critSect); - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Timed out stopping the render IOProc. " - "We may have failed to detect a device removal."); + LOG(LS_WARNING) + << "Timed out stopping the render IOProc." + << "We may have failed to detect a device removal."; // We assume capturing on a shared device has stopped as well if the // IOProc times out. @@ -1598,7 +1577,7 @@ int32_t AudioDeviceMac::StopPlayout() { } _critSect.Enter(); _doStop = false; - WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id, "Playout stopped"); + LOG(LS_VERBOSE) << "Playout stopped"; } // Setting this signal will allow the worker thread to be stopped. @@ -1660,8 +1639,7 @@ int32_t AudioDeviceMac::SetPlayoutBuffer( const AudioDeviceModule::BufferType type, uint16_t sizeMS) { if (type != AudioDeviceModule::kFixedBufferSize) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " Adaptive buffer size not supported on this platform"); + LOG(LS_ERROR) << "Adaptive buffer size not supported on this platform"; return -1; } @@ -1680,8 +1658,7 @@ int32_t AudioDeviceMac::PlayoutBuffer(AudioDeviceModule::BufferType& type, // Not implemented for Mac. int32_t AudioDeviceMac::CPULoad(uint16_t& /*load*/) const { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " API call not supported on this platform"); + LOG(LS_WARNING) << "API call not supported on this platform"; return -1; } @@ -1734,7 +1711,7 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, WEBRTC_CA_RETURN_ON_ERR(AudioObjectGetPropertyDataSize( kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size)); if (size == 0) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "No devices"); + LOG(LS_WARNING) << "No devices"; return 0; } @@ -1764,8 +1741,7 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, scopedDeviceIds[numberScopedDevices] = usedID; numberScopedDevices++; } else { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "GetNumberDevices(): Default device unknown"); + LOG(LS_WARNING) << "GetNumberDevices(): Default device unknown"; } // Then list the rest of the devices @@ -1801,8 +1777,7 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, if (bufferList->mNumberBuffers > 0) { if (numberScopedDevices >= deviceListLength) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Device list is not long enough"); + LOG(LS_ERROR) << "Device list is not long enough"; listOK = false; break; } @@ -1850,7 +1825,7 @@ int32_t AudioDeviceMac::GetDeviceName(const AudioObjectPropertyScope scope, if (numberDevices < 0) { return -1; } else if (numberDevices == 0) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "No devices"); + LOG(LS_ERROR) << "No devices"; return -1; } @@ -1874,8 +1849,7 @@ int32_t AudioDeviceMac::GetDeviceName(const AudioObjectPropertyScope scope, WEBRTC_CA_RETURN_ON_ERR(AudioObjectGetPropertyData( kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size, &usedID)); if (usedID == kAudioDeviceUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "GetDeviceName(): Default device unknown"); + LOG(LS_WARNING) << "GetDeviceName(): Default device unknown"; } else { isDefaultDevice = true; } @@ -1932,8 +1906,7 @@ int32_t AudioDeviceMac::InitDevice(const uint16_t userDeviceIndex, if (numberDevices < 0) { return -1; } else if (numberDevices == 0) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "InitDevice(): No devices"); + LOG(LS_ERROR) << "InitDevice(): No devices"; return -1; } @@ -1945,8 +1918,7 @@ int32_t AudioDeviceMac::InitDevice(const uint16_t userDeviceIndex, WEBRTC_CA_RETURN_ON_ERR(AudioObjectGetPropertyData( kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size, &deviceId)); if (deviceId == kAudioDeviceUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " No default device exists"); + LOG(LS_WARNING) << "No default device exists"; } else { isDefaultDevice = true; } @@ -1976,11 +1948,9 @@ int32_t AudioDeviceMac::InitDevice(const uint16_t userDeviceIndex, 0, NULL, &size, devManf)); if (isInput) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, " Input device: %s %s", - devManf, devName); + LOG(LS_VERBOSE) << "Input device: " << devManf << " " << devName; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, " Output device: %s %s", - devManf, devName); + LOG(LS_VERBOSE) << "Output device: " << devManf << " " << devName; } return 0; @@ -2075,10 +2045,10 @@ OSStatus AudioDeviceMac::SetDesiredPlayoutFormat() { _renderLatencyUs += static_cast((1.0e6 * latency) / _outStreamFormat.mSampleRate); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " initial playout status: _renderDelayOffsetSamples=%d," - " _renderDelayUs=%d, _renderLatencyUs=%d", - _renderDelayOffsetSamples, _renderDelayUs, _renderLatencyUs); + LOG(LS_VERBOSE) << "initial playout status: _renderDelayOffsetSamples=" + << _renderDelayOffsetSamples << ", _renderDelayUs=" + << _renderDelayUs << ", _renderLatencyUs=" + << _renderLatencyUs; return 0; } @@ -2100,8 +2070,7 @@ OSStatus AudioDeviceMac::implObjectListenerProc( const AudioObjectID objectId, const UInt32 numberAddresses, const AudioObjectPropertyAddress addresses[]) { - WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id, - "AudioDeviceMac::implObjectListenerProc()"); + LOG(LS_VERBOSE) << "AudioDeviceMac::implObjectListenerProc()"; for (UInt32 i = 0; i < numberAddresses; i++) { if (addresses[i].mSelector == kAudioHardwarePropertyDevices) { @@ -2121,8 +2090,7 @@ OSStatus AudioDeviceMac::implObjectListenerProc( int32_t AudioDeviceMac::HandleDeviceChange() { OSStatus err = noErr; - WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id, - "kAudioHardwarePropertyDevices"); + LOG(LS_VERBOSE) << "kAudioHardwarePropertyDevices"; // A device has changed. Check if our registered devices have been removed. // Ensure the devices have been initialized, meaning the IDs are valid. @@ -2135,17 +2103,15 @@ int32_t AudioDeviceMac::HandleDeviceChange() { &size, &deviceIsAlive); if (err == kAudioHardwareBadDeviceError || deviceIsAlive == 0) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "Capture device is not alive (probably removed)"); + LOG(LS_WARNING) << "Capture device is not alive (probably removed)"; AtomicSet32(&_captureDeviceIsAlive, 0); _mixerManager.CloseMicrophone(); if (_recError == 1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " pending recording error exists"); + LOG(LS_WARNING) << "pending recording error exists"; } _recError = 1; // triggers callback from module process thread } else if (err != noErr) { - logCAMsg(kTraceError, kTraceAudioDevice, _id, + logCAMsg(rtc::LS_ERROR, "Error in AudioDeviceGetProperty()", (const char*)&err); return -1; } @@ -2160,17 +2126,15 @@ int32_t AudioDeviceMac::HandleDeviceChange() { &size, &deviceIsAlive); if (err == kAudioHardwareBadDeviceError || deviceIsAlive == 0) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "Render device is not alive (probably removed)"); + LOG(LS_WARNING) << "Render device is not alive (probably removed)"; AtomicSet32(&_renderDeviceIsAlive, 0); _mixerManager.CloseSpeaker(); if (_playError == 1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " pending playout error exists"); + LOG(LS_WARNING) << "pending playout error exists"; } _playError = 1; // triggers callback from module process thread } else if (err != noErr) { - logCAMsg(kTraceError, kTraceAudioDevice, _id, + logCAMsg(rtc::LS_ERROR, "Error in AudioDeviceGetProperty()", (const char*)&err); return -1; } @@ -2184,7 +2148,7 @@ int32_t AudioDeviceMac::HandleStreamFormatChange( const AudioObjectPropertyAddress propertyAddress) { OSStatus err = noErr; - WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id, "Stream format changed"); + LOG(LS_VERBOSE) << "Stream format changed"; if (objectId != _inputDeviceID && objectId != _outputDeviceID) { return 0; @@ -2197,32 +2161,27 @@ int32_t AudioDeviceMac::HandleStreamFormatChange( objectId, &propertyAddress, 0, NULL, &size, &streamFormat)); if (streamFormat.mFormatID != kAudioFormatLinearPCM) { - logCAMsg(kTraceError, kTraceAudioDevice, _id, + logCAMsg(rtc::LS_ERROR, "Unacceptable input stream format -> mFormatID", (const char*)&streamFormat.mFormatID); return -1; } if (streamFormat.mChannelsPerFrame > N_DEVICE_CHANNELS) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Too many channels on device (mChannelsPerFrame = %d)", - streamFormat.mChannelsPerFrame); + LOG(LS_ERROR) << "Too many channels on device (mChannelsPerFrame = " + << streamFormat.mChannelsPerFrame << ")"; return -1; } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Stream format:"); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "mSampleRate = %f, mChannelsPerFrame = %u", - streamFormat.mSampleRate, streamFormat.mChannelsPerFrame); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "mBytesPerPacket = %u, mFramesPerPacket = %u", - streamFormat.mBytesPerPacket, streamFormat.mFramesPerPacket); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "mBytesPerFrame = %u, mBitsPerChannel = %u", - streamFormat.mBytesPerFrame, streamFormat.mBitsPerChannel); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "mFormatFlags = %u", - streamFormat.mFormatFlags); - logCAMsg(kTraceInfo, kTraceAudioDevice, _id, "mFormatID", + LOG(LS_VERBOSE) << "Stream format:"; + LOG(LS_VERBOSE) << "mSampleRate = " << streamFormat.mSampleRate + << ", mChannelsPerFrame = " << streamFormat.mChannelsPerFrame; + LOG(LS_VERBOSE) << "mBytesPerPacket = " << streamFormat.mBytesPerPacket + << ", mFramesPerPacket = " << streamFormat.mFramesPerPacket; + LOG(LS_VERBOSE) << "mBytesPerFrame = " << streamFormat.mBytesPerFrame + << ", mBitsPerChannel = " << streamFormat.mBitsPerChannel; + LOG(LS_VERBOSE) << "mFormatFlags = " << streamFormat.mFormatFlags; + logCAMsg(rtc::LS_VERBOSE, "mFormatID", (const char*)&streamFormat.mFormatID); if (propertyAddress.mScope == kAudioDevicePropertyScopeInput) { @@ -2230,9 +2189,9 @@ int32_t AudioDeviceMac::HandleStreamFormatChange( streamFormat.mSampleRate / 100 * N_BLOCKS_IO; if (io_block_size_samples > _captureBufSizeSamples) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Input IO block size (%d) is larger than ring buffer (%u)", - io_block_size_samples, _captureBufSizeSamples); + LOG(LS_ERROR) << "Input IO block size (" << io_block_size_samples + << ") is larger than ring buffer (" + << _captureBufSizeSamples << ")"; return -1; } @@ -2244,8 +2203,7 @@ int32_t AudioDeviceMac::HandleStreamFormatChange( // Disable stereo recording when we only have one channel on the device. _inDesiredFormat.mChannelsPerFrame = 1; _recChannels = 1; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "Stereo recording unavailable on this device"); + LOG(LS_VERBOSE) << "Stereo recording unavailable on this device"; } if (_ptrAudioBuffer) { @@ -2266,8 +2224,7 @@ int32_t AudioDeviceMac::HandleStreamFormatChange( // Our preferred format to work with if (_outStreamFormat.mChannelsPerFrame < 2) { _playChannels = 1; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "Stereo playout unavailable on this device"); + LOG(LS_VERBOSE) << "Stereo playout unavailable on this device"; } WEBRTC_CA_RETURN_ON_ERR(SetDesiredPlayoutFormat()); } @@ -2281,7 +2238,7 @@ int32_t AudioDeviceMac::HandleDataSourceChange( if (_macBookPro && propertyAddress.mScope == kAudioDevicePropertyScopeOutput) { - WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id, "Data source changed"); + LOG(LS_VERBOSE) << "Data source changed"; _macBookProPanRight = false; UInt32 dataSource = 0; @@ -2290,11 +2247,10 @@ int32_t AudioDeviceMac::HandleDataSourceChange( objectId, &propertyAddress, 0, NULL, &size, &dataSource)); if (dataSource == 'ispk') { _macBookProPanRight = true; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "MacBook Pro using internal speakers; stereo panning right"); + LOG(LS_VERBOSE) + << "MacBook Pro using internal speakers; stereo panning right"; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "MacBook Pro not using internal speakers"); + LOG(LS_VERBOSE) << "MacBook Pro not using internal speakers"; } } @@ -2309,13 +2265,11 @@ int32_t AudioDeviceMac::HandleProcessorOverload( // We don't log the notification, as it's sent from the HAL's IO thread. We // don't want to slow it down even further. if (propertyAddress.mScope == kAudioDevicePropertyScopeInput) { - // WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "Capture processor - // overload"); + // LOG(LS_WARNING) << "Capture processor // overload"; //_callback->ProblemIsReported( // SndCardStreamObserver::ERecordingProblem); } else { - // WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - // "Render processor overload"); + // LOG(LS_WARNING) << "Render processor overload"; //_callback->ProblemIsReported( // SndCardStreamObserver::EPlaybackProblem); } @@ -2406,8 +2360,7 @@ OSStatus AudioDeviceMac::implDeviceIOProc(const AudioBufferList* inputData, WEBRTC_CA_LOG_WARN( AudioDeviceDestroyIOProcID(_outputDeviceID, _deviceIOProcID)); if (err == noErr) { - WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id, - " Playout or shared device stopped"); + LOG(LS_VERBOSE) << "Playout or shared device stopped"; } } @@ -2436,11 +2389,10 @@ OSStatus AudioDeviceMac::implDeviceIOProc(const AudioBufferList* inputData, if (err != noErr) { if (err == 1) { // This is our own error. - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " Error in AudioConverterFillComplexBuffer()"); + LOG(LS_ERROR) << "Error in AudioConverterFillComplexBuffer()"; return 1; } else { - logCAMsg(kTraceError, kTraceAudioDevice, _id, + logCAMsg(rtc::LS_ERROR, "Error in AudioConverterFillComplexBuffer()", (const char*)&err); return 1; } @@ -2478,8 +2430,7 @@ OSStatus AudioDeviceMac::implOutConverterProc(UInt32* numberDataPackets, kern_return_t kernErr = semaphore_signal_all(_renderSemaphore); if (kernErr != KERN_SUCCESS) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " semaphore_signal_all() error: %d", kernErr); + LOG(LS_ERROR) << "semaphore_signal_all() error: " << kernErr; return 1; } @@ -2502,8 +2453,7 @@ OSStatus AudioDeviceMac::implInDeviceIOProc(const AudioBufferList* inputData, WEBRTC_CA_LOG_WARN( AudioDeviceDestroyIOProcID(_inputDeviceID, _inDeviceIOProcID)); if (err == noErr) { - WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id, - " Recording device stopped"); + LOG(LS_VERBOSE) << "Recording device stopped"; } _doStopRec = false; @@ -2540,8 +2490,7 @@ OSStatus AudioDeviceMac::implInDeviceIOProc(const AudioBufferList* inputData, kern_return_t kernErr = semaphore_signal_all(_captureSemaphore); if (kernErr != KERN_SUCCESS) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " semaphore_signal_all() error: %d", kernErr); + LOG(LS_ERROR) << "semaphore_signal_all() error: " << kernErr; } return err; @@ -2567,8 +2516,7 @@ OSStatus AudioDeviceMac::implInConverterProc(UInt32* numberDataPackets, return 1; } } else if (kernErr != KERN_SUCCESS) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " semaphore_wait() error: %d", kernErr); + LOG(LS_ERROR) << "semaphore_wait() error: " << kernErr; } } @@ -2610,16 +2558,14 @@ bool AudioDeviceMac::RenderWorkerThread() { return false; } } else if (kernErr != KERN_SUCCESS) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " semaphore_timedwait() error: %d", kernErr); + LOG(LS_ERROR) << "semaphore_timedwait() error: " << kernErr; } } int8_t playBuffer[4 * ENGINE_PLAY_BUF_SIZE_IN_SAMPLES]; if (!_ptrAudioBuffer) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " capture AudioBuffer is invalid"); + LOG(LS_ERROR) << "capture AudioBuffer is invalid"; return false; } @@ -2629,8 +2575,7 @@ bool AudioDeviceMac::RenderWorkerThread() { nSamples = _ptrAudioBuffer->GetPlayoutData(playBuffer); if (nSamples != ENGINE_PLAY_BUF_SIZE_IN_SAMPLES) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " invalid number of output samples(%d)", nSamples); + LOG(LS_ERROR) << "invalid number of output samples(" << nSamples << ")"; } uint32_t nOutSamples = nSamples * _outDesiredFormat.mChannelsPerFrame; @@ -2685,7 +2630,7 @@ bool AudioDeviceMac::CaptureWorkerThread() { // This is our own error. return false; } else { - logCAMsg(kTraceError, kTraceAudioDevice, _id, + logCAMsg(rtc::LS_ERROR, "Error in AudioConverterFillComplexBuffer()", (const char*)&err); return false; } @@ -2707,8 +2652,7 @@ bool AudioDeviceMac::CaptureWorkerThread() { static_cast(1e-3 * (captureDelayUs + _captureLatencyUs) + 0.5); if (!_ptrAudioBuffer) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " capture AudioBuffer is invalid"); + LOG(LS_ERROR) << "capture AudioBuffer is invalid"; return false; } @@ -2744,13 +2688,11 @@ bool AudioDeviceMac::CaptureWorkerThread() { // a change is needed. // Set this new mic level (received from the observer as return // value in the callback). - WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, - " AGC change of volume: old=%u => new=%u", - currentMicLevel, newMicLevel); + LOG(LS_VERBOSE) << "AGC change of volume: old=" << currentMicLevel + << " => new=" << newMicLevel; if (SetMicrophoneVolume(newMicLevel) == -1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " the required modification of the microphone " - "volume failed"); + LOG(LS_WARNING) + << "the required modification of the microphone volume failed"; } } } diff --git a/webrtc/modules/audio_device/mac/audio_device_mac.h b/webrtc/modules/audio_device/mac/audio_device_mac.h index 0acf752ac4..66903823dd 100644 --- a/webrtc/modules/audio_device/mac/audio_device_mac.h +++ b/webrtc/modules/audio_device/mac/audio_device_mac.h @@ -16,6 +16,7 @@ #include "webrtc/modules/audio_device/audio_device_generic.h" #include "webrtc/modules/audio_device/mac/audio_mixer_manager_mac.h" #include "webrtc/rtc_base/criticalsection.h" +#include "webrtc/rtc_base/logging.h" #include "webrtc/rtc_base/thread_annotations.h" #include "webrtc/system_wrappers/include/event_wrapper.h" @@ -61,7 +62,7 @@ const int kGetMicVolumeIntervalMs = 1000; class AudioDeviceMac : public AudioDeviceGeneric { public: - AudioDeviceMac(const int32_t id); + AudioDeviceMac(); ~AudioDeviceMac(); // Retrieve the currently utilized audio layer @@ -189,9 +190,7 @@ class AudioDeviceMac : public AudioDeviceGeneric { static void AtomicSet32(int32_t* theValue, int32_t newValue); static int32_t AtomicGet32(int32_t* theValue); - static void logCAMsg(const TraceLevel level, - const TraceModule module, - const int32_t id, + static void logCAMsg(const rtc::LoggingSeverity sev, const char* msg, const char* err); @@ -297,8 +296,6 @@ class AudioDeviceMac : public AudioDeviceGeneric { // Only valid/running between calls to StartPlayout and StopPlayout. std::unique_ptr render_worker_thread_; - int32_t _id; - AudioMixerManagerMac _mixerManager; uint16_t _inputDeviceIndex; diff --git a/webrtc/modules/audio_device/mac/audio_mixer_manager_mac.cc b/webrtc/modules/audio_device/mac/audio_mixer_manager_mac.cc index 3347a02d51..457fd9ebce 100644 --- a/webrtc/modules/audio_device/mac/audio_mixer_manager_mac.cc +++ b/webrtc/modules/audio_device/mac/audio_mixer_manager_mac.cc @@ -18,7 +18,7 @@ namespace webrtc { do { \ err = expr; \ if (err != noErr) { \ - logCAMsg(kTraceError, kTraceAudioDevice, _id, "Error in " #expr, \ + logCAMsg(rtc::LS_ERROR, "Error in " #expr, \ (const char*) & err); \ return -1; \ } \ @@ -28,7 +28,7 @@ namespace webrtc { do { \ err = expr; \ if (err != noErr) { \ - logCAMsg(kTraceError, kTraceAudioDevice, _id, "Error in " #expr, \ + logCAMsg(rtc::LS_ERROR, "Error in " #expr, \ (const char*) & err); \ } \ } while (0) @@ -37,24 +37,21 @@ namespace webrtc { do { \ err = expr; \ if (err != noErr) { \ - logCAMsg(kTraceWarning, kTraceAudioDevice, _id, "Error in " #expr, \ + logCAMsg(rtc::LS_WARNING, "Error in " #expr, \ (const char*) & err); \ } \ } while (0) -AudioMixerManagerMac::AudioMixerManagerMac(const int32_t id) - : _id(id), - _inputDeviceID(kAudioObjectUnknown), +AudioMixerManagerMac::AudioMixerManagerMac() + : _inputDeviceID(kAudioObjectUnknown), _outputDeviceID(kAudioObjectUnknown), _noInputChannels(0), _noOutputChannels(0) { - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s constructed", - __FUNCTION__); + LOG(LS_INFO) << __FUNCTION__ << " created"; } AudioMixerManagerMac::~AudioMixerManagerMac() { - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s destructed", - __FUNCTION__); + LOG(LS_INFO) << __FUNCTION__ << " destroyed"; Close(); } @@ -63,7 +60,7 @@ AudioMixerManagerMac::~AudioMixerManagerMac() { // ============================================================================ int32_t AudioMixerManagerMac::Close() { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; rtc::CritScope lock(&_critSect); @@ -74,7 +71,7 @@ int32_t AudioMixerManagerMac::Close() { } int32_t AudioMixerManagerMac::CloseSpeaker() { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; rtc::CritScope lock(&_critSect); @@ -85,7 +82,7 @@ int32_t AudioMixerManagerMac::CloseSpeaker() { } int32_t AudioMixerManagerMac::CloseMicrophone() { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; rtc::CritScope lock(&_critSect); @@ -96,8 +93,7 @@ int32_t AudioMixerManagerMac::CloseMicrophone() { } int32_t AudioMixerManagerMac::OpenSpeaker(AudioDeviceID deviceID) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioMixerManagerMac::OpenSpeaker(id=%d)", deviceID); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::OpenSpeaker(id=" << deviceID << ")"; rtc::CritScope lock(&_critSect); @@ -116,17 +112,14 @@ int32_t AudioMixerManagerMac::OpenSpeaker(AudioDeviceID deviceID) { _outputDeviceID, &propertyAddress, 0, NULL, &size, &hogPid)); if (hogPid == -1) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " No process has hogged the input device"); + LOG(LS_VERBOSE) << "No process has hogged the input device"; } // getpid() is apparently "always successful" else if (hogPid == getpid()) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " Our process has hogged the input device"); + LOG(LS_VERBOSE) << "Our process has hogged the input device"; } else { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Another process (pid = %d) has hogged the input device", - static_cast(hogPid)); + LOG(LS_WARNING) << "Another process (pid = " << static_cast(hogPid) + << ") has hogged the input device"; return -1; } @@ -147,8 +140,8 @@ int32_t AudioMixerManagerMac::OpenSpeaker(AudioDeviceID deviceID) { } int32_t AudioMixerManagerMac::OpenMicrophone(AudioDeviceID deviceID) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioMixerManagerMac::OpenMicrophone(id=%d)", deviceID); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::OpenMicrophone(id=" << deviceID + << ")"; rtc::CritScope lock(&_critSect); @@ -165,17 +158,14 @@ int32_t AudioMixerManagerMac::OpenMicrophone(AudioDeviceID deviceID) { WEBRTC_CA_RETURN_ON_ERR(AudioObjectGetPropertyData( _inputDeviceID, &propertyAddress, 0, NULL, &size, &hogPid)); if (hogPid == -1) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " No process has hogged the input device"); + LOG(LS_VERBOSE) << "No process has hogged the input device"; } // getpid() is apparently "always successful" else if (hogPid == getpid()) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " Our process has hogged the input device"); + LOG(LS_VERBOSE) << "Our process has hogged the input device"; } else { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Another process (pid = %d) has hogged the input device", - static_cast(hogPid)); + LOG(LS_WARNING) << "Another process (pid = " << static_cast(hogPid) + << ") has hogged the input device"; return -1; } @@ -196,26 +186,25 @@ int32_t AudioMixerManagerMac::OpenMicrophone(AudioDeviceID deviceID) { } bool AudioMixerManagerMac::SpeakerIsInitialized() const { - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_INFO) << __FUNCTION__; return (_outputDeviceID != kAudioObjectUnknown); } bool AudioMixerManagerMac::MicrophoneIsInitialized() const { - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_INFO) << __FUNCTION__; return (_inputDeviceID != kAudioObjectUnknown); } int32_t AudioMixerManagerMac::SetSpeakerVolume(uint32_t volume) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioMixerManagerMac::SetSpeakerVolume(volume=%u)", volume); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::SetSpeakerVolume(volume=" << volume + << ")"; rtc::CritScope lock(&_critSect); if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -258,8 +247,7 @@ int32_t AudioMixerManagerMac::SetSpeakerVolume(uint32_t volume) { } if (!success) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Unable to set a volume on any output channel"); + LOG(LS_WARNING) << "Unable to set a volume on any output channel"; return -1; } @@ -268,8 +256,7 @@ int32_t AudioMixerManagerMac::SetSpeakerVolume(uint32_t volume) { int32_t AudioMixerManagerMac::SpeakerVolume(uint32_t& volume) const { if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -310,8 +297,7 @@ int32_t AudioMixerManagerMac::SpeakerVolume(uint32_t& volume) const { } if (channels == 0) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Unable to get a volume on any channel"); + LOG(LS_WARNING) << "Unable to get a volume on any channel"; return -1; } @@ -320,16 +306,14 @@ int32_t AudioMixerManagerMac::SpeakerVolume(uint32_t& volume) const { volume = static_cast(255 * vol / channels + 0.5); } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " AudioMixerManagerMac::SpeakerVolume() => vol=%i", vol); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::SpeakerVolume() => vol=" << vol; return 0; } int32_t AudioMixerManagerMac::MaxSpeakerVolume(uint32_t& maxVolume) const { if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -342,8 +326,7 @@ int32_t AudioMixerManagerMac::MaxSpeakerVolume(uint32_t& maxVolume) const { int32_t AudioMixerManagerMac::MinSpeakerVolume(uint32_t& minVolume) const { if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -356,8 +339,7 @@ int32_t AudioMixerManagerMac::MinSpeakerVolume(uint32_t& minVolume) const { int32_t AudioMixerManagerMac::SpeakerVolumeStepSize(uint16_t& stepSize) const { if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -370,8 +352,7 @@ int32_t AudioMixerManagerMac::SpeakerVolumeStepSize(uint16_t& stepSize) const { int32_t AudioMixerManagerMac::SpeakerVolumeIsAvailable(bool& available) { if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -397,9 +378,8 @@ int32_t AudioMixerManagerMac::SpeakerVolumeIsAvailable(bool& available) { &isSettable); if (err != noErr || !isSettable) { available = false; - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Volume cannot be set for output channel %d, err=%d", i, - err); + LOG(LS_WARNING) << "Volume cannot be set for output channel " << i + << ", err=" << err; return -1; } } @@ -410,8 +390,7 @@ int32_t AudioMixerManagerMac::SpeakerVolumeIsAvailable(bool& available) { int32_t AudioMixerManagerMac::SpeakerMuteIsAvailable(bool& available) { if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -437,8 +416,8 @@ int32_t AudioMixerManagerMac::SpeakerMuteIsAvailable(bool& available) { &isSettable); if (err != noErr || !isSettable) { available = false; - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Mute cannot be set for output channel %d, err=%d", i, err); + LOG(LS_WARNING) << "Mute cannot be set for output channel " << i + << ", err=" << err; return -1; } } @@ -448,14 +427,13 @@ int32_t AudioMixerManagerMac::SpeakerMuteIsAvailable(bool& available) { } int32_t AudioMixerManagerMac::SetSpeakerMute(bool enable) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioMixerManagerMac::SetSpeakerMute(enable=%u)", enable); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::SetSpeakerMute(enable=" << enable + << ")"; rtc::CritScope lock(&_critSect); if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -494,8 +472,7 @@ int32_t AudioMixerManagerMac::SetSpeakerMute(bool enable) { } if (!success) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Unable to set mute on any input channel"); + LOG(LS_WARNING) << "Unable to set mute on any input channel"; return -1; } @@ -504,8 +481,7 @@ int32_t AudioMixerManagerMac::SetSpeakerMute(bool enable) { int32_t AudioMixerManagerMac::SpeakerMute(bool& enabled) const { if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -545,8 +521,7 @@ int32_t AudioMixerManagerMac::SpeakerMute(bool& enabled) const { } if (channels == 0) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Unable to get mute for any channel"); + LOG(LS_WARNING) << "Unable to get mute for any channel"; return -1; } @@ -555,17 +530,15 @@ int32_t AudioMixerManagerMac::SpeakerMute(bool& enabled) const { enabled = static_cast(muted); } - WEBRTC_TRACE( - kTraceInfo, kTraceAudioDevice, _id, - " AudioMixerManagerMac::SpeakerMute() => enabled=%d, enabled"); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::SpeakerMute() => enabled=" + << enabled; return 0; } int32_t AudioMixerManagerMac::StereoPlayoutIsAvailable(bool& available) { if (_outputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -575,8 +548,7 @@ int32_t AudioMixerManagerMac::StereoPlayoutIsAvailable(bool& available) { int32_t AudioMixerManagerMac::StereoRecordingIsAvailable(bool& available) { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -586,8 +558,7 @@ int32_t AudioMixerManagerMac::StereoRecordingIsAvailable(bool& available) { int32_t AudioMixerManagerMac::MicrophoneMuteIsAvailable(bool& available) { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -613,8 +584,8 @@ int32_t AudioMixerManagerMac::MicrophoneMuteIsAvailable(bool& available) { &isSettable); if (err != noErr || !isSettable) { available = false; - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Mute cannot be set for output channel %d, err=%d", i, err); + LOG(LS_WARNING) << "Mute cannot be set for output channel " << i + << ", err=" << err; return -1; } } @@ -624,14 +595,13 @@ int32_t AudioMixerManagerMac::MicrophoneMuteIsAvailable(bool& available) { } int32_t AudioMixerManagerMac::SetMicrophoneMute(bool enable) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioMixerManagerMac::SetMicrophoneMute(enable=%u)", enable); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::SetMicrophoneMute(enable=" << enable + << ")"; rtc::CritScope lock(&_critSect); if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -670,8 +640,7 @@ int32_t AudioMixerManagerMac::SetMicrophoneMute(bool enable) { } if (!success) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Unable to set mute on any input channel"); + LOG(LS_WARNING) << "Unable to set mute on any input channel"; return -1; } @@ -680,8 +649,7 @@ int32_t AudioMixerManagerMac::SetMicrophoneMute(bool enable) { int32_t AudioMixerManagerMac::MicrophoneMute(bool& enabled) const { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -721,8 +689,7 @@ int32_t AudioMixerManagerMac::MicrophoneMute(bool& enabled) const { } if (channels == 0) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Unable to get mute for any channel"); + LOG(LS_WARNING) << "Unable to get mute for any channel"; return -1; } @@ -731,17 +698,15 @@ int32_t AudioMixerManagerMac::MicrophoneMute(bool& enabled) const { enabled = static_cast(muted); } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " AudioMixerManagerMac::MicrophoneMute() => enabled=%d", - enabled); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::MicrophoneMute() => enabled=" + << enabled; return 0; } int32_t AudioMixerManagerMac::MicrophoneBoostIsAvailable(bool& available) { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -751,14 +716,13 @@ int32_t AudioMixerManagerMac::MicrophoneBoostIsAvailable(bool& available) { } int32_t AudioMixerManagerMac::SetMicrophoneBoost(bool enable) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioMixerManagerMac::SetMicrophoneBoost(enable=%u)", enable); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::SetMicrophoneBoost(enable=" + << enable << ")"; rtc::CritScope lock(&_critSect); if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -766,8 +730,7 @@ int32_t AudioMixerManagerMac::SetMicrophoneBoost(bool enable) { bool available(false); MicrophoneBoostIsAvailable(available); if (!available) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " it is not possible to enable microphone boost"); + LOG(LS_WARNING) << "it is not possible to enable microphone boost"; return -1; } @@ -777,8 +740,7 @@ int32_t AudioMixerManagerMac::SetMicrophoneBoost(bool enable) { int32_t AudioMixerManagerMac::MicrophoneBoost(bool& enabled) const { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -790,8 +752,7 @@ int32_t AudioMixerManagerMac::MicrophoneBoost(bool& enabled) const { int32_t AudioMixerManagerMac::MicrophoneVolumeIsAvailable(bool& available) { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -817,9 +778,8 @@ int32_t AudioMixerManagerMac::MicrophoneVolumeIsAvailable(bool& available) { &isSettable); if (err != noErr || !isSettable) { available = false; - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Volume cannot be set for input channel %d, err=%d", i, - err); + LOG(LS_WARNING) << "Volume cannot be set for input channel " << i + << ", err=" << err; return -1; } } @@ -829,14 +789,13 @@ int32_t AudioMixerManagerMac::MicrophoneVolumeIsAvailable(bool& available) { } int32_t AudioMixerManagerMac::SetMicrophoneVolume(uint32_t volume) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioMixerManagerMac::SetMicrophoneVolume(volume=%u)", volume); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::SetMicrophoneVolume(volume=" + << volume << ")"; rtc::CritScope lock(&_critSect); if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -879,8 +838,7 @@ int32_t AudioMixerManagerMac::SetMicrophoneVolume(uint32_t volume) { } if (!success) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Unable to set a level on any input channel"); + LOG(LS_WARNING) << "Unable to set a level on any input channel"; return -1; } @@ -889,8 +847,7 @@ int32_t AudioMixerManagerMac::SetMicrophoneVolume(uint32_t volume) { int32_t AudioMixerManagerMac::MicrophoneVolume(uint32_t& volume) const { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -931,8 +888,7 @@ int32_t AudioMixerManagerMac::MicrophoneVolume(uint32_t& volume) const { } if (channels == 0) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " Unable to get a level on any channel"); + LOG(LS_WARNING) << "Unable to get a level on any channel"; return -1; } @@ -941,17 +897,15 @@ int32_t AudioMixerManagerMac::MicrophoneVolume(uint32_t& volume) const { volume = static_cast(255 * volFloat32 / channels + 0.5); } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " AudioMixerManagerMac::MicrophoneVolume() => vol=%u", - volume); + LOG(LS_VERBOSE) << "AudioMixerManagerMac::MicrophoneVolume() => vol=" + << volume; return 0; } int32_t AudioMixerManagerMac::MaxMicrophoneVolume(uint32_t& maxVolume) const { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -964,8 +918,7 @@ int32_t AudioMixerManagerMac::MaxMicrophoneVolume(uint32_t& maxVolume) const { int32_t AudioMixerManagerMac::MinMicrophoneVolume(uint32_t& minVolume) const { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -979,8 +932,7 @@ int32_t AudioMixerManagerMac::MinMicrophoneVolume(uint32_t& minVolume) const { int32_t AudioMixerManagerMac::MicrophoneVolumeStepSize( uint16_t& stepSize) const { if (_inputDeviceID == kAudioObjectUnknown) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " device ID has not been set"); + LOG(LS_WARNING) << "device ID has not been set"; return -1; } @@ -996,20 +948,36 @@ int32_t AudioMixerManagerMac::MicrophoneVolumeStepSize( // ============================================================================ // CoreAudio errors are best interpreted as four character strings. -void AudioMixerManagerMac::logCAMsg(const TraceLevel level, - const TraceModule module, - const int32_t id, - const char* msg, - const char* err) { - assert(msg != NULL); - assert(err != NULL); +void AudioMixerManagerMac::logCAMsg(const rtc::LoggingSeverity sev, + const char* msg, + const char* err) { + RTC_DCHECK(msg != NULL); + RTC_DCHECK(err != NULL); + RTC_DCHECK(sev == rtc::LS_ERROR || sev == rtc::LS_WARNING); #ifdef WEBRTC_ARCH_BIG_ENDIAN - WEBRTC_TRACE(level, module, id, "%s: %.4s", msg, err); + switch (sev) { + case rtc::LS_ERROR: + LOG(LS_ERROR) << msg << ": " << err[0] << err[1] << err[2] << err[3]; + break; + case rtc::LS_WARNING: + LOG(LS_WARNING) << msg << ": " << err[0] << err[1] << err[2] << err[3]; + break; + default: + break; + } #else // We need to flip the characters in this case. - WEBRTC_TRACE(level, module, id, "%s: %.1s%.1s%.1s%.1s", msg, err + 3, err + 2, - err + 1, err); + switch (sev) { + case rtc::LS_ERROR: + LOG(LS_ERROR) << msg << ": " << err[3] << err[2] << err[1] << err[0]; + break; + case rtc::LS_WARNING: + LOG(LS_WARNING) << msg << ": " << err[3] << err[2] << err[1] << err[0]; + break; + default: + break; + } #endif } diff --git a/webrtc/modules/audio_device/mac/audio_mixer_manager_mac.h b/webrtc/modules/audio_device/mac/audio_mixer_manager_mac.h index 17e7b25e1d..b74fe660ee 100644 --- a/webrtc/modules/audio_device/mac/audio_mixer_manager_mac.h +++ b/webrtc/modules/audio_device/mac/audio_mixer_manager_mac.h @@ -13,7 +13,7 @@ #include "webrtc/modules/audio_device/include/audio_device.h" #include "webrtc/rtc_base/criticalsection.h" -#include "webrtc/system_wrappers/include/trace.h" +#include "webrtc/rtc_base/logging.h" #include "webrtc/typedefs.h" #include @@ -54,19 +54,16 @@ class AudioMixerManagerMac { bool MicrophoneIsInitialized() const; public: - AudioMixerManagerMac(const int32_t id); + AudioMixerManagerMac(); ~AudioMixerManagerMac(); private: - static void logCAMsg(const TraceLevel level, - const TraceModule module, - const int32_t id, + static void logCAMsg(const rtc::LoggingSeverity sev, const char* msg, const char* err); private: rtc::CriticalSection _critSect; - int32_t _id; AudioDeviceID _inputDeviceID; AudioDeviceID _outputDeviceID; 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 2b0a3adfd8..783e9898de 100644 --- a/webrtc/modules/audio_device/win/audio_device_core_win.cc +++ b/webrtc/modules/audio_device/win/audio_device_core_win.cc @@ -35,10 +35,11 @@ #include #include +#include + #include "webrtc/rtc_base/logging.h" #include "webrtc/rtc_base/platform_thread.h" #include "webrtc/system_wrappers/include/sleep.h" -#include "webrtc/system_wrappers/include/trace.h" // Macro that calls a COM method returning HRESULT value. #define EXIT_ON_ERROR(hres) do { if (FAILED(hres)) goto Exit; } while(0) @@ -181,7 +182,7 @@ private: bool AudioDeviceWindowsCore::CoreAudioIsSupported() { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, -1, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; bool MMDeviceIsAvailable(false); bool coreAudioIsSupported(false); @@ -223,9 +224,9 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() dwlConditionMask); if (isVistaRTMorXP != 0) { - WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, -1, - "*** Windows Core Audio is only supported on Vista SP1 or later " - "=> will revert to the Wave API ***"); + LOG(LS_VERBOSE) + << "*** Windows Core Audio is only supported on Vista SP1 or later" + << " => will revert to the Wave API ***"; return false; } @@ -276,10 +277,12 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() if (FAILED(hr)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, -1, - "AudioDeviceWindowsCore::CoreAudioIsSupported() Failed to create the required COM object", hr); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, -1, - "AudioDeviceWindowsCore::CoreAudioIsSupported() CoCreateInstance(MMDeviceEnumerator) failed (hr=0x%x)", hr); + LOG(LS_ERROR) << "AudioDeviceWindowsCore::CoreAudioIsSupported()" + << " Failed to create the required COM object (hr=" + << hr << ")"; + LOG(LS_VERBOSE) << "AudioDeviceWindowsCore::CoreAudioIsSupported()" + << " CoCreateInstance(MMDeviceEnumerator) failed (hr=" + << hr << ")"; const DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; @@ -306,13 +309,14 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() StringCchPrintf(buf, MAXERRORLENGTH, TEXT("Error details: ")); StringCchCat(buf, MAXERRORLENGTH, errorText); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, -1, "%S", buf); + LOG(LS_VERBOSE) << buf; } else { MMDeviceIsAvailable = true; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, -1, - "AudioDeviceWindowsCore::CoreAudioIsSupported() CoCreateInstance(MMDeviceEnumerator) succeeded", hr); + LOG(LS_VERBOSE) << "AudioDeviceWindowsCore::CoreAudioIsSupported()" + << " CoCreateInstance(MMDeviceEnumerator) succeeded (hr=" << hr + << ")"; SAFE_RELEASE(pIMMD); } @@ -324,7 +328,7 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() { coreAudioIsSupported = false; - AudioDeviceWindowsCore* p = new AudioDeviceWindowsCore(-1); + AudioDeviceWindowsCore* p = new AudioDeviceWindowsCore(); if (p == NULL) { return false; @@ -351,8 +355,10 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() } if (ok) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, -1, - "AudioDeviceWindowsCore::CoreAudioIsSupported() Failed to use Core Audio Recording for device id=%i", i); + LOG(LS_WARNING) + << "AudioDeviceWindowsCore::CoreAudioIsSupported()" + << " Failed to use Core Audio Recording for device id=" + << i; } } @@ -369,8 +375,9 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() } if (ok) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, -1 , - "AudioDeviceWindowsCore::CoreAudioIsSupported() Failed to use Core Audio Playout for device id=%i", i); + LOG(LS_WARNING) + << "AudioDeviceWindowsCore::CoreAudioIsSupported()" + << " Failed to use Core Audio Playout for device id=" << i; } } @@ -386,11 +393,12 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() if (coreAudioIsSupported) { - WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, -1, "*** Windows Core Audio is supported ***"); + LOG(LS_VERBOSE) << "*** Windows Core Audio is supported ***"; } else { - WEBRTC_TRACE(kTraceStateInfo, kTraceAudioDevice, -1, "*** Windows Core Audio is NOT supported => will revert to the Wave API ***"); + LOG(LS_VERBOSE) << "*** Windows Core Audio is NOT supported" + << " => will revert to the Wave API ***"; } return (coreAudioIsSupported); @@ -404,9 +412,8 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() // AudioDeviceWindowsCore() - ctor // ---------------------------------------------------------------------------- -AudioDeviceWindowsCore::AudioDeviceWindowsCore(const int32_t id) +AudioDeviceWindowsCore::AudioDeviceWindowsCore() : _comInit(ScopedCOMInitializer::kMTA), - _id(id), _ptrAudioBuffer(NULL), _ptrEnumerator(NULL), _ptrRenderCollection(NULL), @@ -472,7 +479,7 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore(const int32_t id) _inputDeviceIndex(0), _outputDeviceIndex(0), _newMicLevel(0) { - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, "%s created", __FUNCTION__); + LOG(LS_INFO) << __FUNCTION__ << " created"; assert(_comInit.succeeded()); // Try to load the Avrt DLL @@ -482,9 +489,8 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore(const int32_t id) if (_avrtLibrary) { // Handle is valid (should only happen if OS larger than vista & win7). // Try to get the function addresses. - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioDeviceWindowsCore::AudioDeviceWindowsCore() The Avrt " - "DLL module is now loaded"); + LOG(LS_VERBOSE) << "AudioDeviceWindowsCore::AudioDeviceWindowsCore()" + << " The Avrt DLL module is now loaded"; _PAvRevertMmThreadCharacteristics = (PAvRevertMmThreadCharacteristics)GetProcAddress( @@ -497,15 +503,12 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore(const int32_t id) if (_PAvRevertMmThreadCharacteristics && _PAvSetMmThreadCharacteristicsA && _PAvSetMmThreadPriority) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioDeviceWindowsCore::AudioDeviceWindowsCore() " - "AvRevertMmThreadCharacteristics() is OK"); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioDeviceWindowsCore::AudioDeviceWindowsCore() " - "AvSetMmThreadCharacteristicsA() is OK"); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioDeviceWindowsCore::AudioDeviceWindowsCore() " - "AvSetMmThreadPriority() is OK"); + LOG(LS_VERBOSE) << "AudioDeviceWindowsCore::AudioDeviceWindowsCore()" + << " AvRevertMmThreadCharacteristics() is OK"; + LOG(LS_VERBOSE) << "AudioDeviceWindowsCore::AudioDeviceWindowsCore()" + << " AvSetMmThreadCharacteristicsA() is OK"; + LOG(LS_VERBOSE) << "AudioDeviceWindowsCore::AudioDeviceWindowsCore()" + << " AvSetMmThreadPriority() is OK"; _winSupportAvrt = true; } } @@ -573,7 +576,7 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore(const int32_t id) AudioDeviceWindowsCore::~AudioDeviceWindowsCore() { - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s destroyed", __FUNCTION__); + LOG(LS_INFO) << __FUNCTION__ << " destroyed"; Terminate(); @@ -630,13 +633,15 @@ AudioDeviceWindowsCore::~AudioDeviceWindowsCore() BOOL freeOK = FreeLibrary(_avrtLibrary); if (!freeOK) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "AudioDeviceWindowsCore::~AudioDeviceWindowsCore() failed to free the loaded Avrt DLL module correctly"); + LOG(LS_WARNING) + << "AudioDeviceWindowsCore::~AudioDeviceWindowsCore()" + << " failed to free the loaded Avrt DLL module correctly"; } else { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "AudioDeviceWindowsCore::~AudioDeviceWindowsCore() the Avrt DLL module is now unloaded"); + LOG(LS_WARNING) + << "AudioDeviceWindowsCore::~AudioDeviceWindowsCore()" + << " the Avrt DLL module is now unloaded"; } } } @@ -766,7 +771,8 @@ int32_t AudioDeviceWindowsCore::InitSpeaker() int16_t nDevices = PlayoutDevices(); if (_outputDeviceIndex > (nDevices - 1)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "current device selection is invalid => unable to initialize"); + LOG(LS_ERROR) << "current device selection is invalid => unable to" + << " initialize"; return -1; } } @@ -789,7 +795,7 @@ int32_t AudioDeviceWindowsCore::InitSpeaker() if (ret != 0 || (_ptrDeviceOut == NULL)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "failed to initialize the rendering enpoint device"); + LOG(LS_ERROR) << "failed to initialize the rendering enpoint device"; SAFE_RELEASE(_ptrDeviceOut); return -1; } @@ -801,8 +807,7 @@ int32_t AudioDeviceWindowsCore::InitSpeaker() (void**)&pManager); if (ret != 0 || pManager == NULL) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " failed to initialize the render manager"); + LOG(LS_ERROR) << "failed to initialize the render manager"; SAFE_RELEASE(pManager); return -1; } @@ -811,8 +816,7 @@ int32_t AudioDeviceWindowsCore::InitSpeaker() ret = pManager->GetSimpleAudioVolume(NULL, FALSE, &_ptrRenderSimpleVolume); if (ret != 0 || _ptrRenderSimpleVolume == NULL) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " failed to initialize the render simple volume"); + LOG(LS_ERROR) << "failed to initialize the render simple volume"; SAFE_RELEASE(pManager); SAFE_RELEASE(_ptrRenderSimpleVolume); return -1; @@ -848,7 +852,8 @@ int32_t AudioDeviceWindowsCore::InitMicrophone() int16_t nDevices = RecordingDevices(); if (_inputDeviceIndex > (nDevices - 1)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "current device selection is invalid => unable to initialize"); + LOG(LS_ERROR) << "current device selection is invalid => unable to" + << " initialize"; return -1; } } @@ -871,7 +876,7 @@ int32_t AudioDeviceWindowsCore::InitMicrophone() if (ret != 0 || (_ptrDeviceIn == NULL)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "failed to initialize the capturing enpoint device"); + LOG(LS_ERROR) << "failed to initialize the capturing enpoint device"; SAFE_RELEASE(_ptrDeviceIn); return -1; } @@ -883,8 +888,7 @@ int32_t AudioDeviceWindowsCore::InitMicrophone() reinterpret_cast(&_ptrCaptureVolume)); if (ret != 0 || _ptrCaptureVolume == NULL) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " failed to initialize the capture volume"); + LOG(LS_ERROR) << "failed to initialize the capture volume"; SAFE_RELEASE(_ptrCaptureVolume); return -1; } @@ -1548,7 +1552,8 @@ Exit: int32_t AudioDeviceWindowsCore::SetMicrophoneVolume(uint32_t volume) { - WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, "AudioDeviceWindowsCore::SetMicrophoneVolume(volume=%u)", volume); + LOG(LS_VERBOSE) << "AudioDeviceWindowsCore::SetMicrophoneVolume(volume=" + << volume << ")"; { rtc::CritScope lock(&_critSect); @@ -1634,7 +1639,7 @@ Exit: int32_t AudioDeviceWindowsCore::MaxMicrophoneVolume(uint32_t& maxVolume) const { - WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; if (!_microphoneIsInitialized) { @@ -1714,7 +1719,8 @@ int32_t AudioDeviceWindowsCore::SetPlayoutDevice(uint16_t index) if (index < 0 || index > (nDevices-1)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "device index is out of range [0,%u]", (nDevices-1)); + LOG(LS_ERROR) << "device index is out of range [0," << (nDevices-1) + << "]"; return -1; } @@ -1742,7 +1748,7 @@ int32_t AudioDeviceWindowsCore::SetPlayoutDevice(uint16_t index) // Get the endpoint device's friendly-name if (_GetDeviceName(_ptrDeviceOut, szDeviceName, bufferLen) == 0) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "friendly name: \"%S\"", szDeviceName); + LOG(LS_VERBOSE) << "friendly name: \"" << szDeviceName << "\""; } _usingOutputDeviceIndex = true; @@ -1801,7 +1807,7 @@ int32_t AudioDeviceWindowsCore::SetPlayoutDevice(AudioDeviceModule::WindowsDevic // Get the endpoint device's friendly-name if (_GetDeviceName(_ptrDeviceOut, szDeviceName, bufferLen) == 0) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "friendly name: \"%S\"", szDeviceName); + LOG(LS_VERBOSE) << "friendly name: \"" << szDeviceName << "\""; } _usingOutputDeviceIndex = false; @@ -1828,7 +1834,7 @@ int32_t AudioDeviceWindowsCore::PlayoutDeviceName( { defaultCommunicationDevice = true; index = 0; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Default Communication endpoint device will be used"); + LOG(LS_VERBOSE) << "Default Communication endpoint device will be used"; } if ((index > (nDevices-1)) || (name == NULL)) @@ -1864,7 +1870,9 @@ int32_t AudioDeviceWindowsCore::PlayoutDeviceName( // Convert the endpoint device's friendly-name to UTF-8 if (WideCharToMultiByte(CP_UTF8, 0, szDeviceName, -1, name, kAdmMaxDeviceNameSize, NULL, NULL) == 0) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d", GetLastError()); + LOG(LS_ERROR) + << "WideCharToMultiByte(CP_UTF8) failed with error code " + << GetLastError(); } } @@ -1883,7 +1891,9 @@ int32_t AudioDeviceWindowsCore::PlayoutDeviceName( // Convert the endpoint device's ID string to UTF-8 if (WideCharToMultiByte(CP_UTF8, 0, szDeviceName, -1, guid, kAdmMaxGuidSize, NULL, NULL) == 0) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d", GetLastError()); + LOG(LS_ERROR) + << "WideCharToMultiByte(CP_UTF8) failed with error code " + << GetLastError(); } } @@ -1908,7 +1918,7 @@ int32_t AudioDeviceWindowsCore::RecordingDeviceName( { defaultCommunicationDevice = true; index = 0; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Default Communication endpoint device will be used"); + LOG(LS_VERBOSE) << "Default Communication endpoint device will be used"; } if ((index > (nDevices-1)) || (name == NULL)) @@ -1944,7 +1954,9 @@ int32_t AudioDeviceWindowsCore::RecordingDeviceName( // Convert the endpoint device's friendly-name to UTF-8 if (WideCharToMultiByte(CP_UTF8, 0, szDeviceName, -1, name, kAdmMaxDeviceNameSize, NULL, NULL) == 0) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d", GetLastError()); + LOG(LS_ERROR) + << "WideCharToMultiByte(CP_UTF8) failed with error code " + << GetLastError(); } } @@ -1963,7 +1975,9 @@ int32_t AudioDeviceWindowsCore::RecordingDeviceName( // Convert the endpoint device's ID string to UTF-8 if (WideCharToMultiByte(CP_UTF8, 0, szDeviceName, -1, guid, kAdmMaxGuidSize, NULL, NULL) == 0) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d", GetLastError()); + LOG(LS_ERROR) + << "WideCharToMultiByte(CP_UTF8) failed with error code " + << GetLastError(); } } @@ -2004,7 +2018,8 @@ int32_t AudioDeviceWindowsCore::SetRecordingDevice(uint16_t index) if (index < 0 || index > (nDevices-1)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "device index is out of range [0,%u]", (nDevices-1)); + LOG(LS_ERROR) << "device index is out of range [0," << (nDevices-1) + << "]"; return -1; } @@ -2032,7 +2047,7 @@ int32_t AudioDeviceWindowsCore::SetRecordingDevice(uint16_t index) // Get the endpoint device's friendly-name if (_GetDeviceName(_ptrDeviceIn, szDeviceName, bufferLen) == 0) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "friendly name: \"%S\"", szDeviceName); + LOG(LS_VERBOSE) << "friendly name: \"" << szDeviceName << "\""; } _usingInputDeviceIndex = true; @@ -2091,7 +2106,7 @@ int32_t AudioDeviceWindowsCore::SetRecordingDevice(AudioDeviceModule::WindowsDev // Get the endpoint device's friendly-name if (_GetDeviceName(_ptrDeviceIn, szDeviceName, bufferLen) == 0) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "friendly name: \"%S\"", szDeviceName); + LOG(LS_VERBOSE) << "friendly name: \"" << szDeviceName << "\""; } _usingInputDeviceIndex = false; @@ -2173,7 +2188,7 @@ int32_t AudioDeviceWindowsCore::InitPlayout() // Initialize the speaker (devices might have been added or removed) if (InitSpeaker() == -1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "InitSpeaker() failed"); + LOG(LS_WARNING) << "InitSpeaker() failed"; } // Ensure that the updated rendering endpoint device is valid @@ -2211,20 +2226,22 @@ int32_t AudioDeviceWindowsCore::InitPlayout() hr = _ptrClientOut->GetMixFormat(&pWfxOut); if (SUCCEEDED(hr)) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Audio Engine's current rendering mix format:"); + LOG(LS_VERBOSE) << "Audio Engine's current rendering mix format:"; // format type - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "wFormatTag : 0x%X (%u)", pWfxOut->wFormatTag, pWfxOut->wFormatTag); + LOG(LS_VERBOSE) << "wFormatTag : 0x" << std::hex + << pWfxOut->wFormatTag << std::dec << " (" + << pWfxOut->wFormatTag << ")"; // number of channels (i.e. mono, stereo...) - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nChannels : %d", pWfxOut->nChannels); + LOG(LS_VERBOSE) << "nChannels : " << pWfxOut->nChannels; // sample rate - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nSamplesPerSec : %d", pWfxOut->nSamplesPerSec); + LOG(LS_VERBOSE) << "nSamplesPerSec : " << pWfxOut->nSamplesPerSec; // for buffer estimation - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nAvgBytesPerSec: %d", pWfxOut->nAvgBytesPerSec); + LOG(LS_VERBOSE) << "nAvgBytesPerSec: " << pWfxOut->nAvgBytesPerSec; // block size of data - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nBlockAlign : %d", pWfxOut->nBlockAlign); + LOG(LS_VERBOSE) << "nBlockAlign : " << pWfxOut->nBlockAlign; // number of bits per sample of mono data - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "wBitsPerSample : %d", pWfxOut->wBitsPerSample); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "cbSize : %d", pWfxOut->cbSize); + LOG(LS_VERBOSE) << "wBitsPerSample : " << pWfxOut->wBitsPerSample; + LOG(LS_VERBOSE) << "cbSize : " << pWfxOut->cbSize; } // Set wave format @@ -2295,19 +2312,21 @@ int32_t AudioDeviceWindowsCore::InitPlayout() _devicePlayBlockSize = Wfx.nSamplesPerSec/100; _playChannels = Wfx.nChannels; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "VoE selected this rendering format:"); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "wFormatTag : 0x%X (%u)", Wfx.wFormatTag, Wfx.wFormatTag); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nChannels : %d", Wfx.nChannels); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nSamplesPerSec : %d", Wfx.nSamplesPerSec); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nAvgBytesPerSec : %d", Wfx.nAvgBytesPerSec); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nBlockAlign : %d", Wfx.nBlockAlign); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "wBitsPerSample : %d", Wfx.wBitsPerSample); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "cbSize : %d", Wfx.cbSize); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Additional settings:"); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_playAudioFrameSize: %d", _playAudioFrameSize); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "_playBlockSizeInFrames : %d", _playBlockSizeInFrames); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_playChannels : %d", _playChannels); + LOG(LS_VERBOSE) << "VoE selected this rendering format:"; + LOG(LS_VERBOSE) << "wFormatTag : 0x" << std::hex + << Wfx.wFormatTag << std::dec << " (" << Wfx.wFormatTag + << ")"; + LOG(LS_VERBOSE) << "nChannels : " << Wfx.nChannels; + LOG(LS_VERBOSE) << "nSamplesPerSec : " << Wfx.nSamplesPerSec; + LOG(LS_VERBOSE) << "nAvgBytesPerSec : " << Wfx.nAvgBytesPerSec; + LOG(LS_VERBOSE) << "nBlockAlign : " << Wfx.nBlockAlign; + LOG(LS_VERBOSE) << "wBitsPerSample : " << Wfx.wBitsPerSample; + LOG(LS_VERBOSE) << "cbSize : " << Wfx.cbSize; + LOG(LS_VERBOSE) << "Additional settings:"; + LOG(LS_VERBOSE) << "_playAudioFrameSize: " << _playAudioFrameSize; + LOG(LS_VERBOSE) << "_playBlockSizeInFrames : " + << _playBlockSizeInFrames; + LOG(LS_VERBOSE) << "_playChannels : " << _playChannels; } // Create a rendering stream. @@ -2347,7 +2366,7 @@ int32_t AudioDeviceWindowsCore::InitPlayout() if (FAILED(hr)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "IAudioClient::Initialize() failed:"); + LOG(LS_ERROR) << "IAudioClient::Initialize() failed:"; } EXIT_ON_ERROR(hr); @@ -2362,7 +2381,8 @@ int32_t AudioDeviceWindowsCore::InitPlayout() // We can enter this state during CoreAudioIsSupported() when no AudioDeviceImplementation // has been created, hence the AudioDeviceBuffer does not exist. // It is OK to end up here since we don't initiate any media in CoreAudioIsSupported(). - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioDeviceBuffer must be attached before streaming can start"); + LOG(LS_VERBOSE) + << "AudioDeviceBuffer must be attached before streaming can start"; } // Get the actual size of the shared (endpoint buffer). @@ -2372,8 +2392,9 @@ int32_t AudioDeviceWindowsCore::InitPlayout() &bufferFrameCount); if (SUCCEEDED(hr)) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "IAudioClient::GetBufferSize() => %u (<=> %u bytes)", - bufferFrameCount, bufferFrameCount*_playAudioFrameSize); + LOG(LS_VERBOSE) << "IAudioClient::GetBufferSize() => " + << bufferFrameCount << " (<=> " + << bufferFrameCount*_playAudioFrameSize << " bytes)"; } // Set the event handle that the system signals when an audio buffer is ready @@ -2395,7 +2416,7 @@ int32_t AudioDeviceWindowsCore::InitPlayout() CoTaskMemFree(pWfxOut); CoTaskMemFree(pWfxClosestMatch); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "render side is now initialized"); + LOG(LS_VERBOSE) << "render side is now initialized"; return 0; Exit: @@ -2470,8 +2491,8 @@ int32_t AudioDeviceWindowsCore::InitRecordingDMO() else { // Refer to InitRecording() for comments. - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "AudioDeviceBuffer must be attached before streaming can start"); + LOG(LS_VERBOSE) + << "AudioDeviceBuffer must be attached before streaming can start"; } _mediaBuffer = new MediaBufferImpl(_recBlockSize * _recAudioFrameSize); @@ -2485,8 +2506,7 @@ int32_t AudioDeviceWindowsCore::InitRecordingDMO() } _recIsInitialized = true; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "Capture side is now initialized"); + LOG(LS_VERBOSE) << "Capture side is now initialized"; return 0; } @@ -2524,7 +2544,7 @@ int32_t AudioDeviceWindowsCore::InitRecording() // Initialize the microphone (devices might have been added or removed) if (InitMicrophone() == -1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "InitMicrophone() failed"); + LOG(LS_WARNING) << "InitMicrophone() failed"; } // Ensure that the updated capturing endpoint device is valid @@ -2558,20 +2578,22 @@ int32_t AudioDeviceWindowsCore::InitRecording() hr = _ptrClientIn->GetMixFormat(&pWfxIn); if (SUCCEEDED(hr)) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Audio Engine's current capturing mix format:"); + LOG(LS_VERBOSE) << "Audio Engine's current capturing mix format:"; // format type - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "wFormatTag : 0x%X (%u)", pWfxIn->wFormatTag, pWfxIn->wFormatTag); + LOG(LS_VERBOSE) << "wFormatTag : 0x" << std::hex + << pWfxIn->wFormatTag << std::dec << " (" + << pWfxIn->wFormatTag << ")"; // number of channels (i.e. mono, stereo...) - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nChannels : %d", pWfxIn->nChannels); + LOG(LS_VERBOSE) << "nChannels : " << pWfxIn->nChannels; // sample rate - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nSamplesPerSec : %d", pWfxIn->nSamplesPerSec); + LOG(LS_VERBOSE) << "nSamplesPerSec : " << pWfxIn->nSamplesPerSec; // for buffer estimation - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nAvgBytesPerSec: %d", pWfxIn->nAvgBytesPerSec); + LOG(LS_VERBOSE) << "nAvgBytesPerSec: " << pWfxIn->nAvgBytesPerSec; // block size of data - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nBlockAlign : %d", pWfxIn->nBlockAlign); + LOG(LS_VERBOSE) << "nBlockAlign : " << pWfxIn->nBlockAlign; // number of bits per sample of mono data - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "wBitsPerSample : %d", pWfxIn->wBitsPerSample); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "cbSize : %d", pWfxIn->cbSize); + LOG(LS_VERBOSE) << "wBitsPerSample : " << pWfxIn->wBitsPerSample; + LOG(LS_VERBOSE) << "cbSize : " << pWfxIn->cbSize; } // Set wave format @@ -2638,19 +2660,20 @@ int32_t AudioDeviceWindowsCore::InitRecording() _recBlockSize = Wfx.Format.nSamplesPerSec/100; _recChannels = Wfx.Format.nChannels; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "VoE selected this capturing format:"); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "wFormatTag : 0x%X (%u)", Wfx.Format.wFormatTag, - Wfx.Format.wFormatTag); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nChannels : %d", Wfx.Format.nChannels); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nSamplesPerSec : %d", Wfx.Format.nSamplesPerSec); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nAvgBytesPerSec : %d", Wfx.Format.nAvgBytesPerSec); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "nBlockAlign : %d", Wfx.Format.nBlockAlign); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "wBitsPerSample : %d", Wfx.Format.wBitsPerSample); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "cbSize : %d", Wfx.Format.cbSize); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Additional settings:"); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_recAudioFrameSize: %d", _recAudioFrameSize); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_recBlockSize : %d", _recBlockSize); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_recChannels : %d", _recChannels); + LOG(LS_VERBOSE) << "VoE selected this capturing format:"; + LOG(LS_VERBOSE) << "wFormatTag : 0x" << std::hex + << Wfx.Format.wFormatTag << std::dec + << " (" << Wfx.Format.wFormatTag << ")"; + LOG(LS_VERBOSE) << "nChannels : " << Wfx.Format.nChannels; + LOG(LS_VERBOSE) << "nSamplesPerSec : " << Wfx.Format.nSamplesPerSec; + LOG(LS_VERBOSE) << "nAvgBytesPerSec : " << Wfx.Format.nAvgBytesPerSec; + LOG(LS_VERBOSE) << "nBlockAlign : " << Wfx.Format.nBlockAlign; + LOG(LS_VERBOSE) << "wBitsPerSample : " << Wfx.Format.wBitsPerSample; + LOG(LS_VERBOSE) << "cbSize : " << Wfx.Format.cbSize; + LOG(LS_VERBOSE) << "Additional settings:"; + LOG(LS_VERBOSE) << "_recAudioFrameSize: " << _recAudioFrameSize; + LOG(LS_VERBOSE) << "_recBlockSize : " << _recBlockSize; + LOG(LS_VERBOSE) << "_recChannels : " << _recChannels; } // Create a capturing stream. @@ -2666,7 +2689,7 @@ int32_t AudioDeviceWindowsCore::InitRecording() if (hr != S_OK) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "IAudioClient::Initialize() failed:"); + LOG(LS_ERROR) << "IAudioClient::Initialize() failed:"; } EXIT_ON_ERROR(hr); @@ -2681,7 +2704,8 @@ int32_t AudioDeviceWindowsCore::InitRecording() // We can enter this state during CoreAudioIsSupported() when no AudioDeviceImplementation // has been created, hence the AudioDeviceBuffer does not exist. // It is OK to end up here since we don't initiate any media in CoreAudioIsSupported(). - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "AudioDeviceBuffer must be attached before streaming can start"); + LOG(LS_VERBOSE) + << "AudioDeviceBuffer must be attached before streaming can start"; } // Get the actual size of the shared (endpoint buffer). @@ -2691,8 +2715,9 @@ int32_t AudioDeviceWindowsCore::InitRecording() &bufferFrameCount); if (SUCCEEDED(hr)) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "IAudioClient::GetBufferSize() => %u (<=> %u bytes)", - bufferFrameCount, bufferFrameCount*_recAudioFrameSize); + LOG(LS_VERBOSE) << "IAudioClient::GetBufferSize() => " + << bufferFrameCount << " (<=> " + << bufferFrameCount*_recAudioFrameSize << " bytes)"; } // Set the event handle that the system signals when an audio buffer is ready @@ -2714,7 +2739,7 @@ int32_t AudioDeviceWindowsCore::InitRecording() CoTaskMemFree(pWfxIn); CoTaskMemFree(pWfxClosestMatch); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "capture side is now initialized"); + LOG(LS_VERBOSE) << "capture side is now initialized"; return 0; Exit: @@ -2762,9 +2787,9 @@ int32_t AudioDeviceWindowsCore::StartRecording() { // The DMO won't provide us captured output data unless we // give it render data to process. - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Playout must be started before recording when using the " - "built-in AEC"); + LOG(LS_ERROR) + << "Playout must be started before recording when using" + << " the built-in AEC"; return -1; } } @@ -2778,8 +2803,7 @@ int32_t AudioDeviceWindowsCore::StartRecording() NULL); if (_hRecThread == NULL) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "failed to create the recording thread"); + LOG(LS_ERROR) << "failed to create the recording thread"; return -1; } @@ -2795,8 +2819,7 @@ int32_t AudioDeviceWindowsCore::StartRecording() NULL); if (_hGetCaptureVolumeThread == NULL) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " failed to create the volume getter thread"); + LOG(LS_ERROR) << "failed to create the volume getter thread"; return -1; } @@ -2809,8 +2832,7 @@ int32_t AudioDeviceWindowsCore::StartRecording() NULL); if (_hSetCaptureVolumeThread == NULL) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " failed to create the volume setter thread"); + LOG(LS_ERROR) << "failed to create the volume setter thread"; return -1; } } // critScoped @@ -2818,12 +2840,10 @@ int32_t AudioDeviceWindowsCore::StartRecording() DWORD ret = WaitForSingleObject(_hCaptureStartedEvent, 1000); if (ret != WAIT_OBJECT_0) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "capturing did not start up properly"); + LOG(LS_VERBOSE) << "capturing did not start up properly"; return -1; } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "capture audio stream has now started..."); + LOG(LS_VERBOSE) << "capture audio stream has now started..."; _avgCPULoad = 0.0f; _playAcc = 0; @@ -2849,8 +2869,8 @@ int32_t AudioDeviceWindowsCore::StopRecording() if (_hRecThread == NULL) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "no capturing stream is active => close down WASAPI only"); + LOG(LS_VERBOSE) + << "no capturing stream is active => close down WASAPI only"; SAFE_RELEASE(_ptrClientIn); SAFE_RELEASE(_ptrCaptureClient); _recIsInitialized = false; @@ -2860,8 +2880,7 @@ int32_t AudioDeviceWindowsCore::StopRecording() } // Stop the driving thread... - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "closing down the webrtc_core_audio_capture_thread..."); + LOG(LS_VERBOSE) << "closing down the webrtc_core_audio_capture_thread..."; // Manual-reset event; it will remain signalled to stop all capture threads. SetEvent(_hShutdownCaptureEvent); @@ -2869,42 +2888,37 @@ int32_t AudioDeviceWindowsCore::StopRecording() DWORD ret = WaitForSingleObject(_hRecThread, 2000); if (ret != WAIT_OBJECT_0) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "failed to close down webrtc_core_audio_capture_thread"); + LOG(LS_ERROR) + << "failed to close down webrtc_core_audio_capture_thread"; err = -1; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "webrtc_core_audio_capture_thread is now closed"); + LOG(LS_VERBOSE) << "webrtc_core_audio_capture_thread is now closed"; } ret = WaitForSingleObject(_hGetCaptureVolumeThread, 2000); if (ret != WAIT_OBJECT_0) { // the thread did not stop as it should - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " failed to close down volume getter thread"); + LOG(LS_ERROR) << "failed to close down volume getter thread"; err = -1; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " volume getter thread is now closed"); + LOG(LS_VERBOSE) << "volume getter thread is now closed"; } ret = WaitForSingleObject(_hSetCaptureVolumeThread, 2000); if (ret != WAIT_OBJECT_0) { // the thread did not stop as it should - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - " failed to close down volume setter thread"); + LOG(LS_ERROR) << "failed to close down volume setter thread"; err = -1; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - " volume setter thread is now closed"); + LOG(LS_VERBOSE) << "volume setter thread is now closed"; } _Lock(); @@ -3012,8 +3026,7 @@ int32_t AudioDeviceWindowsCore::StartPlayout() NULL); if (_hPlayThread == NULL) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "failed to create the playout thread"); + LOG(LS_ERROR) << "failed to create the playout thread"; return -1; } @@ -3024,14 +3037,12 @@ int32_t AudioDeviceWindowsCore::StartPlayout() DWORD ret = WaitForSingleObject(_hRenderStartedEvent, 1000); if (ret != WAIT_OBJECT_0) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "rendering did not start up properly"); + LOG(LS_VERBOSE) << "rendering did not start up properly"; return -1; } _playing = true; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "rendering audio stream has now started..."); + LOG(LS_VERBOSE) << "rendering audio stream has now started..."; return 0; } @@ -3053,8 +3064,8 @@ int32_t AudioDeviceWindowsCore::StopPlayout() if (_hPlayThread == NULL) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "no rendering stream is active => close down WASAPI only"); + LOG(LS_VERBOSE) + << "no rendering stream is active => close down WASAPI only"; SAFE_RELEASE(_ptrClientOut); SAFE_RELEASE(_ptrRenderClient); _playIsInitialized = false; @@ -3063,8 +3074,8 @@ int32_t AudioDeviceWindowsCore::StopPlayout() } // stop the driving thread... - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "closing down the webrtc_core_audio_render_thread..."); + LOG(LS_VERBOSE) + << "closing down the webrtc_core_audio_render_thread..."; SetEvent(_hShutdownRenderEvent); } // critScoped @@ -3072,8 +3083,7 @@ int32_t AudioDeviceWindowsCore::StopPlayout() if (ret != WAIT_OBJECT_0) { // the thread did not stop as it should - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "failed to close down webrtc_core_audio_render_thread"); + LOG(LS_ERROR) << "failed to close down webrtc_core_audio_render_thread"; CloseHandle(_hPlayThread); _hPlayThread = NULL; _playIsInitialized = false; @@ -3083,8 +3093,7 @@ int32_t AudioDeviceWindowsCore::StopPlayout() { rtc::CritScope critScoped(&_critSect); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "webrtc_core_audio_render_thread is now closed"); + LOG(LS_VERBOSE) << "webrtc_core_audio_render_thread is now closed"; // to reset this event manually at each time we finish with it, // in case that the render thread has exited before StopPlayout(), @@ -3108,9 +3117,9 @@ int32_t AudioDeviceWindowsCore::StopPlayout() // We still permit the playout to shutdown, and trace a warning. // Otherwise, VoE can get into a state which will never permit // playout to stop properly. - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "Recording should be stopped before playout when using the " - "built-in AEC"); + LOG(LS_WARNING) + << "Recording should be stopped before playout when using the" + << " built-in AEC"; } // Reset the playout delay value. @@ -3347,8 +3356,8 @@ DWORD AudioDeviceWindowsCore::DoGetCaptureVolumeThread() case WAIT_TIMEOUT: // timeout notification break; default: // unexpected error - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " unknown wait termination on get volume thread"); + LOG(LS_WARNING) + << "unknown wait termination on get volume thread"; return 1; } } @@ -3368,8 +3377,8 @@ DWORD AudioDeviceWindowsCore::DoSetCaptureVolumeThread() case WAIT_OBJECT_0 + 1: // _hSetCaptureVolumeEvent break; default: // unexpected error - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " unknown wait termination on set volume thread"); + LOG(LS_WARNING) + << "unknown wait termination on set volume thread"; return 1; } @@ -3379,8 +3388,8 @@ DWORD AudioDeviceWindowsCore::DoSetCaptureVolumeThread() if (SetMicrophoneVolume(newMicLevel) == -1) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - " the required modification of the microphone volume failed"); + LOG(LS_WARNING) + << "the required modification of the microphone volume failed"; } } } @@ -3404,8 +3413,7 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() // Initialize COM as MTA in this thread. ScopedCOMInitializer comInit(ScopedCOMInitializer::kMTA); if (!comInit.succeeded()) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "failed to initialize COM in render thread"); + LOG(LS_ERROR) << "failed to initialize COM in render thread"; return 1; } @@ -3421,13 +3429,16 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() { if (FALSE == _PAvSetMmThreadPriority(hMmTask, AVRT_PRIORITY_CRITICAL)) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "failed to boost play-thread using MMCSS"); + LOG(LS_WARNING) << "failed to boost play-thread using MMCSS"; } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "render thread is now registered with MMCSS (taskIndex=%d)", taskIndex); + LOG(LS_VERBOSE) + << "render thread is now registered with MMCSS (taskIndex=" + << taskIndex << ")"; } else { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "failed to enable MMCSS on render thread (err=%d)", GetLastError()); + LOG(LS_WARNING) << "failed to enable MMCSS on render thread (err=" + << GetLastError() << ")"; _TraceCOMError(GetLastError()); } } @@ -3442,14 +3453,14 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() UINT32 bufferLength = 0; hr = _ptrClientOut->GetBufferSize(&bufferLength); EXIT_ON_ERROR(hr); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[REND] size of buffer : %u", bufferLength); + LOG(LS_VERBOSE) << "[REND] size of buffer : " << bufferLength; // Get maximum latency for the current stream (will not change for the lifetime of the IAudioClient object). // REFERENCE_TIME latency; _ptrClientOut->GetStreamLatency(&latency); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[REND] max stream latency : %u (%3.2f ms)", - (DWORD)latency, (double)(latency/10000.0)); + LOG(LS_VERBOSE) << "[REND] max stream latency : " << (DWORD)latency + << " (" << (double)(latency/10000.0) << " ms)"; // Get the length of the periodic interval separating successive processing passes by // the audio engine on the data in the endpoint buffer. @@ -3463,8 +3474,8 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() REFERENCE_TIME devPeriod = 0; REFERENCE_TIME devPeriodMin = 0; _ptrClientOut->GetDevicePeriod(&devPeriod, &devPeriodMin); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[REND] device period : %u (%3.2f ms)", - (DWORD)devPeriod, (double)(devPeriod/10000.0)); + LOG(LS_VERBOSE) << "[REND] device period : " << (DWORD)devPeriod + << " (" << (double)(devPeriod/10000.0) << " ms)"; // Derive initial rendering delay. // Example: 10*(960/480) + 15 = 20 + 15 = 35ms @@ -3473,11 +3484,10 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() (int)((latency + devPeriod) / 10000); _sndCardPlayDelay = playout_delay; _writtenSamples = 0; - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "[REND] initial delay : %u", playout_delay); + LOG(LS_VERBOSE) << "[REND] initial delay : " << playout_delay; double endpointBufferSizeMS = 10.0 * ((double)bufferLength / (double)_devicePlayBlockSize); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[REND] endpointBufferSizeMS : %3.2f", endpointBufferSizeMS); + LOG(LS_VERBOSE) << "[REND] endpointBufferSizeMS : " << endpointBufferSizeMS; // Before starting the stream, fill the rendering buffer with silence. // @@ -3492,8 +3502,8 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() hr = _ptrClientOut->GetService(__uuidof(IAudioClock), (void**)&clock); if (FAILED(hr)) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "failed to get IAudioClock interface from the IAudioClient"); + LOG(LS_WARNING) + << "failed to get IAudioClock interface from the IAudioClient"; } // Start up the rendering audio stream. @@ -3520,10 +3530,10 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() case WAIT_OBJECT_0 + 1: // _hRenderSamplesReadyEvent break; case WAIT_TIMEOUT: // timeout notification - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "render event timed out after 0.5 seconds"); + LOG(LS_WARNING) << "render event timed out after 0.5 seconds"; goto Exit; default: // unexpected error - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "unknown wait termination on render side"); + LOG(LS_WARNING) << "unknown wait termination on render side"; goto Exit; } @@ -3536,8 +3546,8 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() if (_ptrRenderClient == NULL || _ptrClientOut == NULL) { _UnLock(); - WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, - "output state has been modified during unlocked period"); + LOG(LS_ERROR) + << "output state has been modified during unlocked period"; goto Exit; } @@ -3548,7 +3558,6 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() // Derive the amount of available space in the output buffer uint32_t framesAvailable = bufferLength - padding; - // WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, "#avaliable audio frames = %u", framesAvailable); // Do we have 10 ms available in the render buffer? if (framesAvailable < _playBlockSizeInFrames) { @@ -3580,8 +3589,7 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() if (nSamples == -1) { _UnLock(); - WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, - "failed to read data from render client"); + LOG(LS_ERROR) << "failed to read data from render client"; goto Exit; } @@ -3589,15 +3597,17 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() if (_ptrRenderClient == NULL || _ptrClientOut == NULL) { _UnLock(); - WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, "output state has been modified during unlocked period"); + LOG(LS_ERROR) + << "output state has been modified during unlocked" + << " period"; goto Exit; } if (nSamples != static_cast(_playBlockSizeInSamples)) { - WEBRTC_TRACE( - kTraceWarning, kTraceAudioDevice, _id, - "nSamples(%d) != _playBlockSizeInSamples(%d)", - nSamples, _playBlockSizeInSamples); + LOG(LS_WARNING) + << "nSamples(" << nSamples + << ") != _playBlockSizeInSamples(" + << _playBlockSizeInSamples << ")"; } // Get the actual (stored) data @@ -3675,11 +3685,13 @@ Exit: } // Trigger callback from module process thread _playError = 1; - WEBRTC_TRACE(kTraceError, kTraceUtility, _id, "kPlayoutError message posted: rendering thread has ended pre-maturely"); + LOG(LS_ERROR) + << "kPlayoutError message posted: rendering thread has ended" + << " pre-maturely"; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_Rendering thread is now terminated properly"); + LOG(LS_VERBOSE) << "_Rendering thread is now terminated properly"; } _UnLock(); @@ -3703,18 +3715,16 @@ DWORD AudioDeviceWindowsCore::InitCaptureThreadPriority() { if (!_PAvSetMmThreadPriority(_hMmTask, AVRT_PRIORITY_CRITICAL)) { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "failed to boost rec-thread using MMCSS"); + LOG(LS_WARNING) << "failed to boost rec-thread using MMCSS"; } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "capture thread is now registered with MMCSS (taskIndex=%d)", - taskIndex); + LOG(LS_VERBOSE) + << "capture thread is now registered with MMCSS (taskIndex=" + << taskIndex << ")"; } else { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "failed to enable MMCSS on capture thread (err=%d)", - GetLastError()); + LOG(LS_WARNING) << "failed to enable MMCSS on capture thread (err=" + << GetLastError() << ")"; _TraceCOMError(GetLastError()); } } @@ -3743,8 +3753,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() // Initialize COM as MTA in this thread. ScopedCOMInitializer comInit(ScopedCOMInitializer::kMTA); if (!comInit.succeeded()) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "failed to initialize COM in polling DMO thread"); + LOG(LS_ERROR) << "failed to initialize COM in polling DMO thread"; return 1; } @@ -3772,8 +3781,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() case WAIT_TIMEOUT: // timeout notification break; default: // unexpected error - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, - "Unknown wait termination on capture side"); + LOG(LS_WARNING) << "Unknown wait termination on capture side"; hr = -1; // To signal an error callback. keepRecording = false; break; @@ -3864,14 +3872,12 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() { // Trigger callback from module process thread _recError = 1; - WEBRTC_TRACE(kTraceError, kTraceUtility, _id, - "kRecordingError message posted: capturing thread has ended " - "prematurely"); + LOG(LS_ERROR) << "kRecordingError message posted: capturing thread has" + << " ended prematurely"; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "Capturing thread is now terminated properly"); + LOG(LS_VERBOSE) << "Capturing thread is now terminated properly"; } return hr; @@ -3901,8 +3907,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() // Initialize COM as MTA in this thread. ScopedCOMInitializer comInit(ScopedCOMInitializer::kMTA); if (!comInit.succeeded()) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "failed to initialize COM in capture thread"); + LOG(LS_ERROR) << "failed to initialize COM in capture thread"; return 1; } @@ -3920,13 +3925,13 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() UINT32 bufferLength = 0; if (_ptrClientIn == NULL) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "input state has been modified before capture loop starts."); + LOG(LS_ERROR) + << "input state has been modified before capture loop starts."; return 1; } hr = _ptrClientIn->GetBufferSize(&bufferLength); EXIT_ON_ERROR(hr); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[CAPT] size of buffer : %u", bufferLength); + LOG(LS_VERBOSE) << "[CAPT] size of buffer : " << bufferLength; // Allocate memory for sync buffer. // It is used for compensation between native 44.1 and internal 44.0 and @@ -3938,14 +3943,15 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() { return (DWORD)E_POINTER; } - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[CAPT] size of sync buffer : %u [bytes]", syncBufferSize); + LOG(LS_VERBOSE) << "[CAPT] size of sync buffer : " << syncBufferSize + << " [bytes]"; // Get maximum latency for the current stream (will not change for the lifetime of the IAudioClient object). // REFERENCE_TIME latency; _ptrClientIn->GetStreamLatency(&latency); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[CAPT] max stream latency : %u (%3.2f ms)", - (DWORD)latency, (double)(latency / 10000.0)); + LOG(LS_VERBOSE) << "[CAPT] max stream latency : " << (DWORD)latency + << " (" << (double)(latency / 10000.0) << " ms)"; // Get the length of the periodic interval separating successive processing passes by // the audio engine on the data in the endpoint buffer. @@ -3953,14 +3959,14 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() REFERENCE_TIME devPeriod = 0; REFERENCE_TIME devPeriodMin = 0; _ptrClientIn->GetDevicePeriod(&devPeriod, &devPeriodMin); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[CAPT] device period : %u (%3.2f ms)", - (DWORD)devPeriod, (double)(devPeriod / 10000.0)); + LOG(LS_VERBOSE) << "[CAPT] device period : " << (DWORD)devPeriod + << " (" << (double)(devPeriod / 10000.0) << " ms)"; double extraDelayMS = (double)((latency + devPeriod) / 10000.0); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[CAPT] extraDelayMS : %3.2f", extraDelayMS); + LOG(LS_VERBOSE) << "[CAPT] extraDelayMS : " << extraDelayMS; double endpointBufferSizeMS = 10.0 * ((double)bufferLength / (double)_recBlockSize); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[CAPT] endpointBufferSizeMS : %3.2f", endpointBufferSizeMS); + LOG(LS_VERBOSE) << "[CAPT] endpointBufferSizeMS : " << endpointBufferSizeMS; // Start up the capturing stream. // @@ -3987,10 +3993,10 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() case WAIT_OBJECT_0 + 1: // _hCaptureSamplesReadyEvent break; case WAIT_TIMEOUT: // timeout notification - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "capture event timed out after 0.5 seconds"); + LOG(LS_WARNING) << "capture event timed out after 0.5 seconds"; goto Exit; default: // unexpected error - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "unknown wait termination on capture side"); + LOG(LS_WARNING) << "unknown wait termination on capture side"; goto Exit; } @@ -4009,8 +4015,8 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() if (_ptrCaptureClient == NULL || _ptrClientIn == NULL) { _UnLock(); - WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, - "input state has been modified during unlocked period"); + LOG(LS_ERROR) + << "input state has been modified during unlocked period"; goto Exit; } @@ -4034,7 +4040,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() if (flags & AUDCLNT_BUFFERFLAGS_SILENT) { // Treat all of the data in the packet as silence and ignore the actual data values. - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "AUDCLNT_BUFFERFLAGS_SILENT"); + LOG(LS_WARNING) << "AUDCLNT_BUFFERFLAGS_SILENT"; pData = NULL; } @@ -4100,7 +4106,9 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() if (_ptrCaptureClient == NULL || _ptrClientIn == NULL) { _UnLock(); - WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, "input state has been modified during unlocked period"); + LOG(LS_ERROR) + << "input state has been modified during" + << " unlocked period"; goto Exit; } } @@ -4118,7 +4126,8 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() { // The VQE will only deliver non-zero microphone levels when a change is needed. // Set this new mic level (received from the observer as return value in the callback). - WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id, "AGC change of volume: new=%u", newMicLevel); + LOG(LS_VERBOSE) << "AGC change of volume: new=" + << newMicLevel; // We store this outside of the audio buffer to avoid // having it overwritten by the getter thread. _newMicLevel = newMicLevel; @@ -4133,8 +4142,9 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() // of the failed GetBuffer calls. If GetBuffer returns this error repeatedly, the client // can start a new processing loop after shutting down the current client by calling // IAudioClient::Stop, IAudioClient::Reset, and releasing the audio client. - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "IAudioCaptureClient::GetBuffer returned AUDCLNT_E_BUFFER_ERROR, hr = 0x%08X", hr); + LOG(LS_ERROR) << "IAudioCaptureClient::GetBuffer returned" + << " AUDCLNT_E_BUFFER_ERROR, hr = 0x" + << std::hex << hr << std::dec; goto Exit; } @@ -4179,11 +4189,13 @@ Exit: // Trigger callback from module process thread _recError = 1; - WEBRTC_TRACE(kTraceError, kTraceUtility, _id, "kRecordingError message posted: capturing thread has ended pre-maturely"); + LOG(LS_ERROR) + << "kRecordingError message posted: capturing thread has ended" + << " pre-maturely"; } else { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_Capturing thread is now terminated properly"); + LOG(LS_VERBOSE) << "_Capturing thread is now terminated properly"; } SAFE_RELEASE(_ptrClientIn); @@ -4204,15 +4216,15 @@ int32_t AudioDeviceWindowsCore::EnableBuiltInAEC(bool enable) if (_recIsInitialized) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Attempt to set Windows AEC with recording already initialized"); + LOG(LS_ERROR) + << "Attempt to set Windows AEC with recording already initialized"; return -1; } if (_dmo == NULL) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Built-in AEC DMO was not initialized properly at create time"); + LOG(LS_ERROR) + << "Built-in AEC DMO was not initialized properly at create time"; return -1; } @@ -4328,9 +4340,8 @@ int AudioDeviceWindowsCore::SetDMOProperties() DWORD devIndex = static_cast(outDevIndex << 16) + static_cast(0x0000ffff & inDevIndex); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "Capture device index: %d, render device index: %d", - inDevIndex, outDevIndex); + LOG(LS_VERBOSE) << "Capture device index: " << inDevIndex + << ", render device index: " << outDevIndex; if (SetVtI4Property(ps, MFPKEY_WMAAECMA_DEVICE_INDEXES, devIndex) == -1) @@ -4387,7 +4398,7 @@ int AudioDeviceWindowsCore::SetVtI4Property(IPropertyStore* ptrPS, int32_t AudioDeviceWindowsCore::_RefreshDeviceList(EDataFlow dir) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; HRESULT hr = S_OK; IMMDeviceCollection *pCollection = NULL; @@ -4430,7 +4441,7 @@ int32_t AudioDeviceWindowsCore::_RefreshDeviceList(EDataFlow dir) int16_t AudioDeviceWindowsCore::_DeviceListCount(EDataFlow dir) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; HRESULT hr = S_OK; UINT count = 0; @@ -4468,7 +4479,7 @@ int16_t AudioDeviceWindowsCore::_DeviceListCount(EDataFlow dir) int32_t AudioDeviceWindowsCore::_GetListDeviceName(EDataFlow dir, int index, LPWSTR szBuffer, int bufferLen) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; HRESULT hr = S_OK; IMMDevice *pDevice = NULL; @@ -4507,7 +4518,7 @@ int32_t AudioDeviceWindowsCore::_GetListDeviceName(EDataFlow dir, int index, LPW int32_t AudioDeviceWindowsCore::_GetDefaultDeviceName(EDataFlow dir, ERole role, LPWSTR szBuffer, int bufferLen) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; HRESULT hr = S_OK; IMMDevice *pDevice = NULL; @@ -4546,7 +4557,7 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceName(EDataFlow dir, ERole role, int32_t AudioDeviceWindowsCore::_GetListDeviceID(EDataFlow dir, int index, LPWSTR szBuffer, int bufferLen) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; HRESULT hr = S_OK; IMMDevice *pDevice = NULL; @@ -4585,7 +4596,7 @@ int32_t AudioDeviceWindowsCore::_GetListDeviceID(EDataFlow dir, int index, LPWST int32_t AudioDeviceWindowsCore::_GetDefaultDeviceID(EDataFlow dir, ERole role, LPWSTR szBuffer, int bufferLen) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; HRESULT hr = S_OK; IMMDevice *pDevice = NULL; @@ -4615,7 +4626,7 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceIndex(EDataFlow dir, ERole role, int* index) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; HRESULT hr = S_OK; WCHAR szDefaultDeviceID[MAX_PATH] = {0}; @@ -4641,8 +4652,7 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceIndex(EDataFlow dir, if (!collection) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Device collection not valid"); + LOG(LS_ERROR) << "Device collection not valid"; return -1; } @@ -4687,8 +4697,7 @@ int32_t AudioDeviceWindowsCore::_GetDefaultDeviceIndex(EDataFlow dir, if (*index == -1) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Unable to find collection index for default device"); + LOG(LS_ERROR) << "Unable to find collection index for default device"; return -1; } @@ -4703,7 +4712,7 @@ int32_t AudioDeviceWindowsCore::_GetDeviceName(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; static const WCHAR szDefault[] = L""; @@ -4719,8 +4728,8 @@ int32_t AudioDeviceWindowsCore::_GetDeviceName(IMMDevice* pDevice, hr = pDevice->OpenPropertyStore(STGM_READ, &pProps); if (FAILED(hr)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "IMMDevice::OpenPropertyStore failed, hr = 0x%08X", hr); + LOG(LS_ERROR) << "IMMDevice::OpenPropertyStore failed, hr = 0x" + << std::hex << hr << std::dec; } } @@ -4733,24 +4742,24 @@ int32_t AudioDeviceWindowsCore::_GetDeviceName(IMMDevice* pDevice, hr = pProps->GetValue(PKEY_Device_FriendlyName, &varName); if (FAILED(hr)) { - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "IPropertyStore::GetValue failed, hr = 0x%08X", hr); + LOG(LS_ERROR) << "IPropertyStore::GetValue failed, hr = 0x" + << std::hex << hr << std::dec; } } if ((SUCCEEDED(hr)) && (VT_EMPTY == varName.vt)) { hr = E_FAIL; - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "IPropertyStore::GetValue returned no value, hr = 0x%08X", hr); + LOG(LS_ERROR) << "IPropertyStore::GetValue returned no value," + << " hr = 0x" << std::hex << hr << std::dec; } if ((SUCCEEDED(hr)) && (VT_LPWSTR != varName.vt)) { // The returned value is not a wide null terminated string. hr = E_UNEXPECTED; - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "IPropertyStore::GetValue returned unexpected type, hr = 0x%08X", hr); + LOG(LS_ERROR) << "IPropertyStore::GetValue returned unexpected" + << " type, hr = 0x" << std::hex << hr << std::dec; } if (SUCCEEDED(hr) && (varName.pwszVal != NULL)) @@ -4776,7 +4785,7 @@ int32_t AudioDeviceWindowsCore::_GetDeviceName(IMMDevice* pDevice, int32_t AudioDeviceWindowsCore::_GetDeviceID(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; static const WCHAR szDefault[] = L""; @@ -4812,7 +4821,7 @@ int32_t AudioDeviceWindowsCore::_GetDeviceID(IMMDevice* pDevice, LPWSTR pszBuffe int32_t AudioDeviceWindowsCore::_GetDefaultDevice(EDataFlow dir, ERole role, IMMDevice** ppDevice) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; HRESULT hr(S_OK); @@ -4873,7 +4882,7 @@ int32_t AudioDeviceWindowsCore::_GetListDevice(EDataFlow dir, int index, IMMDevi int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dataFlow) const { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "%s", __FUNCTION__); + LOG(LS_VERBOSE) << __FUNCTION__; assert(_ptrEnumerator != NULL); @@ -4902,9 +4911,11 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dataFlow) hr = pCollection->GetCount(&count); EXIT_ON_ERROR(hr); if (dataFlow == eRender) - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "#rendering endpoint devices (counting all): %u", count); + LOG(LS_VERBOSE) << "#rendering endpoint devices (counting all): " + << count; else if (dataFlow == eCapture) - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "#capturing endpoint devices (counting all): %u", count); + LOG(LS_VERBOSE) << "#capturing endpoint devices (counting all): " + << count; if (count == 0) { @@ -4914,7 +4925,7 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dataFlow) // Each loop prints the name of an endpoint device. for (ULONG i = 0; i < count; i++) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Endpoint %d:", i); + LOG(LS_VERBOSE) << "Endpoint " << i << ":"; // Get pointer to endpoint number i. // Output: IMMDevice interface. @@ -4928,7 +4939,7 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dataFlow) // Get the endpoint ID string (uniquely identifies the device among all audio endpoint devices) hr = pEndpoint->GetId(&pwszID); CONTINUE_ON_ERROR(hr); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "ID string : %S", pwszID); + LOG(LS_VERBOSE) << "ID string : " << pwszID; // Retrieve an interface to the device's property store. // Output: IPropertyStore interface. @@ -4949,20 +4960,24 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dataFlow) PKEY_Device_FriendlyName, &varName); CONTINUE_ON_ERROR(hr); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "friendly name: \"%S\"", varName.pwszVal); + LOG(LS_VERBOSE) << "friendly name: \"" << varName.pwszVal << "\""; // Get the endpoint's current device state DWORD dwState; hr = pEndpoint->GetState(&dwState); CONTINUE_ON_ERROR(hr); if (dwState & DEVICE_STATE_ACTIVE) - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "state (0x%x) : *ACTIVE*", dwState); + LOG(LS_VERBOSE) << "state (0x" << std::hex << dwState << std::dec + << ") : *ACTIVE*"; if (dwState & DEVICE_STATE_DISABLED) - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "state (0x%x) : DISABLED", dwState); + LOG(LS_VERBOSE) << "state (0x" << std::hex << dwState << std::dec + << ") : DISABLED"; if (dwState & DEVICE_STATE_NOTPRESENT) - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "state (0x%x) : NOTPRESENT", dwState); + LOG(LS_VERBOSE) << "state (0x" << std::hex << dwState << std::dec + << ") : NOTPRESENT"; if (dwState & DEVICE_STATE_UNPLUGGED) - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "state (0x%x) : UNPLUGGED", dwState); + LOG(LS_VERBOSE) << "state (0x" << std::hex << dwState << std::dec + << ") : UNPLUGGED"; // Check the hardware volume capabilities. DWORD dwHwSupportMask = 0; @@ -4973,20 +4988,23 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dataFlow) CONTINUE_ON_ERROR(hr); if (dwHwSupportMask & ENDPOINT_HARDWARE_SUPPORT_VOLUME) // The audio endpoint device supports a hardware volume control - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "hwmask (0x%x) : HARDWARE_SUPPORT_VOLUME", dwHwSupportMask); + LOG(LS_VERBOSE) << "hwmask (0x" << std::hex << dwHwSupportMask + << std::dec << ") : HARDWARE_SUPPORT_VOLUME"; if (dwHwSupportMask & ENDPOINT_HARDWARE_SUPPORT_MUTE) // The audio endpoint device supports a hardware mute control - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "hwmask (0x%x) : HARDWARE_SUPPORT_MUTE", dwHwSupportMask); + LOG(LS_VERBOSE) << "hwmask (0x" << std::hex << dwHwSupportMask + << std::dec << ") : HARDWARE_SUPPORT_MUTE"; if (dwHwSupportMask & ENDPOINT_HARDWARE_SUPPORT_METER) // The audio endpoint device supports a hardware peak meter - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "hwmask (0x%x) : HARDWARE_SUPPORT_METER", dwHwSupportMask); + LOG(LS_VERBOSE) << "hwmask (0x" << std::hex << dwHwSupportMask + << std::dec << ") : HARDWARE_SUPPORT_METER"; // Check the channel count (#channels in the audio stream that enters or leaves the audio endpoint device) UINT nChannelCount(0); hr = pEndpointVolume->GetChannelCount( &nChannelCount); CONTINUE_ON_ERROR(hr); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "#channels : %u", nChannelCount); + LOG(LS_VERBOSE) << "#channels : " << nChannelCount; if (dwHwSupportMask & ENDPOINT_HARDWARE_SUPPORT_VOLUME) { @@ -4999,8 +5017,9 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dataFlow) &fLevelMaxDB, &fVolumeIncrementDB); CONTINUE_ON_ERROR(hr); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "volume range : %4.2f (min), %4.2f (max), %4.2f (inc) [dB]", - fLevelMinDB, fLevelMaxDB, fVolumeIncrementDB); + LOG(LS_VERBOSE) << "volume range : " << fLevelMinDB << " (min), " + << fLevelMaxDB << " (max), " << fVolumeIncrementDB + << " (inc) [dB]"; // The volume range from vmin = fLevelMinDB to vmax = fLevelMaxDB is divided // into n uniform intervals of size vinc = fVolumeIncrementDB, where @@ -5008,7 +5027,7 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dataFlow) // The values vmin, vmax, and vinc are measured in decibels. The client can set // the volume level to one of n + 1 discrete values in the range from vmin to vmax. int n = (int)((fLevelMaxDB-fLevelMinDB)/fVolumeIncrementDB); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "#intervals : %d", n); + LOG(LS_VERBOSE) << "#intervals : " << n; // Get information about the current step in the volume range. // This method represents the volume level of the audio stream that enters or leaves @@ -5022,12 +5041,12 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dataFlow) &nStep, &nStepCount); CONTINUE_ON_ERROR(hr); - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "volume steps : %d (nStep), %d (nStepCount)", nStep, nStepCount); + LOG(LS_VERBOSE) << "volume steps : " << nStep << " (nStep), " + << nStepCount << " (nStepCount)"; } Next: if (FAILED(hr)) { - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, - "Error when logging device information"); + LOG(LS_VERBOSE) << "Error when logging device information"; } CoTaskMemFree(pwszID); pwszID = NULL; @@ -5082,11 +5101,10 @@ void AudioDeviceWindowsCore::_TraceCOMError(HRESULT hr) const errorText[messageLength - 1] = '\0'; } - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, - "Core Audio method failed (hr=0x%x)", hr); + LOG(LS_ERROR) << "Core Audio method failed (hr=" << hr << ")"; StringCchPrintf(buf, MAXERRORLENGTH, TEXT("Error details: ")); StringCchCat(buf, MAXERRORLENGTH, errorText); - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "%s", WideToUTF8(buf)); + LOG(LS_ERROR) << WideToUTF8(buf); } // ---------------------------------------------------------------------------- diff --git a/webrtc/modules/audio_device/win/audio_device_core_win.h b/webrtc/modules/audio_device/win/audio_device_core_win.h index 60ee9ef890..24eca550b1 100644 --- a/webrtc/modules/audio_device/win/audio_device_core_win.h +++ b/webrtc/modules/audio_device/win/audio_device_core_win.h @@ -82,7 +82,7 @@ class ScopedCOMInitializer { class AudioDeviceWindowsCore : public AudioDeviceGeneric { public: - AudioDeviceWindowsCore(const int32_t id); + AudioDeviceWindowsCore(); ~AudioDeviceWindowsCore(); static bool CoreAudioIsSupported(); @@ -237,8 +237,6 @@ private: // thread functions void _Lock() { _critSect.Enter(); }; void _UnLock() { _critSect.Leave(); }; - int32_t Id() {return _id;} - int SetDMOProperties(); int SetBoolProperty(IPropertyStore* ptrPS, @@ -274,7 +272,6 @@ private: // thread functions AudioDeviceBuffer* _ptrAudioBuffer; rtc::CriticalSection _critSect; rtc::CriticalSection _volumeMutex; - int32_t _id; IMMDeviceEnumerator* _ptrEnumerator; IMMDeviceCollection* _ptrRenderCollection;