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}
This commit is contained in:
saza 2017-07-19 01:12:36 -07:00 committed by Commit Bot
parent c58f8c0962
commit b4aa4eb06f
7 changed files with 603 additions and 684 deletions

View File

@ -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

View File

@ -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 <ApplicationServices/ApplicationServices.h>
#include <libkern/OSAtomic.h> // 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<uint32_t>((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<int32_t>(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";
}
}
}

View File

@ -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<rtc::PlatformThread> render_worker_thread_;
int32_t _id;
AudioMixerManagerMac _mixerManager;
uint16_t _inputDeviceIndex;

View File

@ -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<int>(hogPid));
LOG(LS_WARNING) << "Another process (pid = " << static_cast<int>(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<int>(hogPid));
LOG(LS_WARNING) << "Another process (pid = " << static_cast<int>(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<uint32_t>(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<bool>(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<bool>(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<uint32_t>(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
}

View File

@ -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 <CoreAudio/CoreAudio.h>
@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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;