| Index: webrtc/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc
|
| diff --git a/webrtc/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc b/webrtc/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc
|
| index 29620eb043a36a0fad89351f961be047ad28ba9e..abc91df8c5e1a37443dbf36f763ef673f6b982fd 100644
|
| --- a/webrtc/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc
|
| +++ b/webrtc/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc
|
| @@ -24,19 +24,18 @@ extern webrtc_adm_linux_alsa::AlsaSymbolTable AlsaSymbolTable;
|
| namespace webrtc
|
| {
|
|
|
| -AudioMixerManagerLinuxALSA::AudioMixerManagerLinuxALSA(const int32_t id) :
|
| - _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
| - _id(id),
|
| - _outputMixerHandle(NULL),
|
| - _inputMixerHandle(NULL),
|
| - _outputMixerElement(NULL),
|
| - _inputMixerElement(NULL)
|
| -{
|
| - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id,
|
| - "%s constructed", __FUNCTION__);
|
| -
|
| - memset(_outputMixerStr, 0, kAdmMaxDeviceNameSize);
|
| - memset(_inputMixerStr, 0, kAdmMaxDeviceNameSize);
|
| +AudioMixerManagerLinuxALSA::AudioMixerManagerLinuxALSA(const int32_t id)
|
| + : _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
| + _id(id),
|
| + _outputMixerHandle(nullptr),
|
| + _inputMixerHandle(nullptr),
|
| + _outputMixerElement(nullptr),
|
| + _inputMixerElement(nullptr) {
|
| + WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s constructed",
|
| + __FUNCTION__);
|
| +
|
| + memset(_outputMixerStr, 0, kAdmMaxDeviceNameSize);
|
| + memset(_inputMixerStr, 0, kAdmMaxDeviceNameSize);
|
| }
|
|
|
| AudioMixerManagerLinuxALSA::~AudioMixerManagerLinuxALSA()
|
| @@ -76,33 +75,28 @@ int32_t AudioMixerManagerLinuxALSA::CloseSpeaker()
|
|
|
| int errVal = 0;
|
|
|
| - if (_outputMixerHandle != NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing playout mixer");
|
| - LATE(snd_mixer_free)(_outputMixerHandle);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error freeing playout mixer: %s",
|
| - LATE(snd_strerror)(errVal));
|
| - }
|
| - errVal = LATE(snd_mixer_detach)(_outputMixerHandle, _outputMixerStr);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error detachinging playout mixer: %s",
|
| - LATE(snd_strerror)(errVal));
|
| - }
|
| - errVal = LATE(snd_mixer_close)(_outputMixerHandle);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error snd_mixer_close(handleMixer) errVal=%d",
|
| - errVal);
|
| - }
|
| - _outputMixerHandle = NULL;
|
| - _outputMixerElement = NULL;
|
| + if (_outputMixerHandle != nullptr) {
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Closing playout mixer");
|
| + LATE(snd_mixer_free)(_outputMixerHandle);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error freeing playout mixer: %s",
|
| + LATE(snd_strerror)(errVal));
|
| + }
|
| + errVal = LATE(snd_mixer_detach)(_outputMixerHandle, _outputMixerStr);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error detachinging playout mixer: %s",
|
| + LATE(snd_strerror)(errVal));
|
| + }
|
| + errVal = LATE(snd_mixer_close)(_outputMixerHandle);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error snd_mixer_close(handleMixer) errVal=%d",
|
| + errVal);
|
| + }
|
| + _outputMixerHandle = nullptr;
|
| + _outputMixerElement = nullptr;
|
| }
|
| memset(_outputMixerStr, 0, kAdmMaxDeviceNameSize);
|
|
|
| @@ -117,43 +111,38 @@ int32_t AudioMixerManagerLinuxALSA::CloseMicrophone()
|
|
|
| int errVal = 0;
|
|
|
| - if (_inputMixerHandle != NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing record mixer");
|
| -
|
| - LATE(snd_mixer_free)(_inputMixerHandle);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error freeing record mixer: %s",
|
| - LATE(snd_strerror)(errVal));
|
| - }
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing record mixer 2");
|
| + if (_inputMixerHandle != nullptr) {
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Closing record mixer");
|
|
|
| - errVal = LATE(snd_mixer_detach)(_inputMixerHandle, _inputMixerStr);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error detachinging record mixer: %s",
|
| - LATE(snd_strerror)(errVal));
|
| - }
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing record mixer 3");
|
| + LATE(snd_mixer_free)(_inputMixerHandle);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error freeing record mixer: %s",
|
| + LATE(snd_strerror)(errVal));
|
| + }
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + "Closing record mixer 2");
|
|
|
| - errVal = LATE(snd_mixer_close)(_inputMixerHandle);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error snd_mixer_close(handleMixer) errVal=%d",
|
| - errVal);
|
| - }
|
| + errVal = LATE(snd_mixer_detach)(_inputMixerHandle, _inputMixerStr);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error detachinging record mixer: %s",
|
| + LATE(snd_strerror)(errVal));
|
| + }
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + "Closing record mixer 3");
|
|
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing record mixer 4");
|
| - _inputMixerHandle = NULL;
|
| - _inputMixerElement = NULL;
|
| + errVal = LATE(snd_mixer_close)(_inputMixerHandle);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error snd_mixer_close(handleMixer) errVal=%d",
|
| + errVal);
|
| + }
|
| +
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + "Closing record mixer 4");
|
| + _inputMixerHandle = nullptr;
|
| + _inputMixerElement = nullptr;
|
| }
|
| memset(_inputMixerStr, 0, kAdmMaxDeviceNameSize);
|
|
|
| @@ -171,35 +160,30 @@ int32_t AudioMixerManagerLinuxALSA::OpenSpeaker(char* deviceName)
|
|
|
| // Close any existing output mixer handle
|
| //
|
| - if (_outputMixerHandle != NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing playout mixer");
|
| + if (_outputMixerHandle != nullptr) {
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Closing playout mixer");
|
|
|
| - LATE(snd_mixer_free)(_outputMixerHandle);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error freeing playout mixer: %s",
|
| - LATE(snd_strerror)(errVal));
|
| - }
|
| - errVal = LATE(snd_mixer_detach)(_outputMixerHandle, _outputMixerStr);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error detachinging playout mixer: %s",
|
| - LATE(snd_strerror)(errVal));
|
| - }
|
| - errVal = LATE(snd_mixer_close)(_outputMixerHandle);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error snd_mixer_close(handleMixer) errVal=%d",
|
| - errVal);
|
| - }
|
| + LATE(snd_mixer_free)(_outputMixerHandle);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error freeing playout mixer: %s",
|
| + LATE(snd_strerror)(errVal));
|
| + }
|
| + errVal = LATE(snd_mixer_detach)(_outputMixerHandle, _outputMixerStr);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error detachinging playout mixer: %s",
|
| + LATE(snd_strerror)(errVal));
|
| + }
|
| + errVal = LATE(snd_mixer_close)(_outputMixerHandle);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error snd_mixer_close(handleMixer) errVal=%d",
|
| + errVal);
|
| + }
|
| }
|
| - _outputMixerHandle = NULL;
|
| - _outputMixerElement = NULL;
|
| + _outputMixerHandle = nullptr;
|
| + _outputMixerElement = nullptr;
|
|
|
| errVal = LATE(snd_mixer_open)(&_outputMixerHandle, 0);
|
| if (errVal < 0)
|
| @@ -221,20 +205,21 @@ int32_t AudioMixerManagerLinuxALSA::OpenSpeaker(char* deviceName)
|
| WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| " snd_mixer_attach(_outputMixerHandle, %s) error: %s",
|
| controlName, LATE(snd_strerror)(errVal));
|
| - _outputMixerHandle = NULL;
|
| + _outputMixerHandle = nullptr;
|
| return -1;
|
| }
|
| strcpy(_outputMixerStr, controlName);
|
|
|
| - errVal = LATE(snd_mixer_selem_register)(_outputMixerHandle, NULL, NULL);
|
| + errVal =
|
| + LATE(snd_mixer_selem_register)(_outputMixerHandle, nullptr, nullptr);
|
| if (errVal < 0)
|
| {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " snd_mixer_selem_register(_outputMixerHandle,"
|
| - " NULL, NULL), error: %s",
|
| - LATE(snd_strerror)(errVal));
|
| - _outputMixerHandle = NULL;
|
| - return -1;
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " snd_mixer_selem_register(_outputMixerHandle,"
|
| + " null, null), error: %s",
|
| + LATE(snd_strerror)(errVal));
|
| + _outputMixerHandle = nullptr;
|
| + return -1;
|
| }
|
|
|
| // Load and find the proper mixer element
|
| @@ -243,11 +228,10 @@ int32_t AudioMixerManagerLinuxALSA::OpenSpeaker(char* deviceName)
|
| return -1;
|
| }
|
|
|
| - if (_outputMixerHandle != NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - " the output mixer device is now open (0x%x)",
|
| - _outputMixerHandle);
|
| + if (_outputMixerHandle != nullptr) {
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + " the output mixer device is now open (0x%x)",
|
| + _outputMixerHandle);
|
| }
|
|
|
| return 0;
|
| @@ -265,43 +249,35 @@ int32_t AudioMixerManagerLinuxALSA::OpenMicrophone(char *deviceName)
|
|
|
| // Close any existing input mixer handle
|
| //
|
| - if (_inputMixerHandle != NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing record mixer");
|
| + if (_inputMixerHandle != nullptr) {
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Closing record mixer");
|
|
|
| - LATE(snd_mixer_free)(_inputMixerHandle);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error freeing record mixer: %s",
|
| - LATE(snd_strerror)(errVal));
|
| - }
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing record mixer");
|
| + LATE(snd_mixer_free)(_inputMixerHandle);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error freeing record mixer: %s",
|
| + LATE(snd_strerror)(errVal));
|
| + }
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Closing record mixer");
|
|
|
| - errVal = LATE(snd_mixer_detach)(_inputMixerHandle, _inputMixerStr);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error detachinging record mixer: %s",
|
| - LATE(snd_strerror)(errVal));
|
| - }
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing record mixer");
|
| + errVal = LATE(snd_mixer_detach)(_inputMixerHandle, _inputMixerStr);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error detachinging record mixer: %s",
|
| + LATE(snd_strerror)(errVal));
|
| + }
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Closing record mixer");
|
|
|
| - errVal = LATE(snd_mixer_close)(_inputMixerHandle);
|
| - if (errVal < 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " Error snd_mixer_close(handleMixer) errVal=%d",
|
| - errVal);
|
| - }
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - "Closing record mixer");
|
| + errVal = LATE(snd_mixer_close)(_inputMixerHandle);
|
| + if (errVal < 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " Error snd_mixer_close(handleMixer) errVal=%d",
|
| + errVal);
|
| + }
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "Closing record mixer");
|
| }
|
| - _inputMixerHandle = NULL;
|
| - _inputMixerElement = NULL;
|
| + _inputMixerHandle = nullptr;
|
| + _inputMixerElement = nullptr;
|
|
|
| errVal = LATE(snd_mixer_open)(&_inputMixerHandle, 0);
|
| if (errVal < 0)
|
| @@ -324,21 +300,22 @@ int32_t AudioMixerManagerLinuxALSA::OpenMicrophone(char *deviceName)
|
| " snd_mixer_attach(_inputMixerHandle, %s) error: %s",
|
| controlName, LATE(snd_strerror)(errVal));
|
|
|
| - _inputMixerHandle = NULL;
|
| + _inputMixerHandle = nullptr;
|
| return -1;
|
| }
|
| strcpy(_inputMixerStr, controlName);
|
|
|
| - errVal = LATE(snd_mixer_selem_register)(_inputMixerHandle, NULL, NULL);
|
| + errVal =
|
| + LATE(snd_mixer_selem_register)(_inputMixerHandle, nullptr, nullptr);
|
| if (errVal < 0)
|
| {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - " snd_mixer_selem_register(_inputMixerHandle,"
|
| - " NULL, NULL), error: %s",
|
| - LATE(snd_strerror)(errVal));
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + " snd_mixer_selem_register(_inputMixerHandle,"
|
| + " null, null), error: %s",
|
| + LATE(snd_strerror)(errVal));
|
|
|
| - _inputMixerHandle = NULL;
|
| - return -1;
|
| + _inputMixerHandle = nullptr;
|
| + return -1;
|
| }
|
| // Load and find the proper mixer element
|
| if (LoadMicMixerElement() < 0)
|
| @@ -346,11 +323,10 @@ int32_t AudioMixerManagerLinuxALSA::OpenMicrophone(char *deviceName)
|
| return -1;
|
| }
|
|
|
| - if (_inputMixerHandle != NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - " the input mixer device is now open (0x%x)",
|
| - _inputMixerHandle);
|
| + if (_inputMixerHandle != nullptr) {
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + " the input mixer device is now open (0x%x)",
|
| + _inputMixerHandle);
|
| }
|
|
|
| return 0;
|
| @@ -360,7 +336,7 @@ bool AudioMixerManagerLinuxALSA::SpeakerIsInitialized() const
|
| {
|
| WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s", __FUNCTION__);
|
|
|
| - return (_outputMixerHandle != NULL);
|
| + return (_outputMixerHandle != nullptr);
|
| }
|
|
|
| bool AudioMixerManagerLinuxALSA::MicrophoneIsInitialized() const
|
| @@ -368,7 +344,7 @@ bool AudioMixerManagerLinuxALSA::MicrophoneIsInitialized() const
|
| WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s",
|
| __FUNCTION__);
|
|
|
| - return (_inputMixerHandle != NULL);
|
| + return (_inputMixerHandle != nullptr);
|
| }
|
|
|
| int32_t AudioMixerManagerLinuxALSA::SetSpeakerVolume(
|
| @@ -380,11 +356,10 @@ int32_t AudioMixerManagerLinuxALSA::SetSpeakerVolume(
|
|
|
| CriticalSectionScoped lock(&_critSect);
|
|
|
| - if (_outputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable output mixer element exists");
|
| - return -1;
|
| + if (_outputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable output mixer element exists");
|
| + return -1;
|
| }
|
|
|
| int errVal =
|
| @@ -404,12 +379,10 @@ int32_t AudioMixerManagerLinuxALSA::SetSpeakerVolume(
|
| int32_t AudioMixerManagerLinuxALSA::SpeakerVolume(
|
| uint32_t& volume) const
|
| {
|
| -
|
| - if (_outputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable output mixer element exists");
|
| - return -1;
|
| + if (_outputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable output mixer element exists");
|
| + return -1;
|
| }
|
|
|
| long int vol(0);
|
| @@ -438,12 +411,10 @@ int32_t AudioMixerManagerLinuxALSA::SpeakerVolume(
|
| int32_t AudioMixerManagerLinuxALSA::MaxSpeakerVolume(
|
| uint32_t& maxVolume) const
|
| {
|
| -
|
| - if (_outputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avilable output mixer element exists");
|
| - return -1;
|
| + if (_outputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avilable output mixer element exists");
|
| + return -1;
|
| }
|
|
|
| long int minVol(0);
|
| @@ -472,12 +443,10 @@ int32_t AudioMixerManagerLinuxALSA::MaxSpeakerVolume(
|
| int32_t AudioMixerManagerLinuxALSA::MinSpeakerVolume(
|
| uint32_t& minVolume) const
|
| {
|
| -
|
| - if (_outputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable output mixer element exists");
|
| - return -1;
|
| + if (_outputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable output mixer element exists");
|
| + return -1;
|
| }
|
|
|
| long int minVol(0);
|
| @@ -514,7 +483,7 @@ int32_t AudioMixerManagerLinuxALSA::MinSpeakerVolume(
|
| uint32_t maxVolume)
|
| {
|
|
|
| - if (_outputMixerElement == NULL)
|
| + if (_outputMixerElement == nullptr)
|
| {
|
| WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| " no avaliable output mixer element exists");
|
| @@ -555,7 +524,7 @@ int32_t AudioMixerManagerLinuxALSA::MinSpeakerVolume(
|
| uint32_t minVolume)
|
| {
|
|
|
| - if (_outputMixerElement == NULL)
|
| + if (_outputMixerElement == nullptr)
|
| {
|
| WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| " no avaliable output mixer element exists");
|
| @@ -592,12 +561,10 @@ int32_t AudioMixerManagerLinuxALSA::MinSpeakerVolume(
|
| int32_t AudioMixerManagerLinuxALSA::SpeakerVolumeStepSize(
|
| uint16_t& stepSize) const
|
| {
|
| -
|
| - if (_outputMixerHandle == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable output mixer exists");
|
| - return -1;
|
| + if (_outputMixerHandle == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable output mixer exists");
|
| + return -1;
|
| }
|
|
|
| // The step size is always 1 for ALSA
|
| @@ -609,11 +576,10 @@ int32_t AudioMixerManagerLinuxALSA::SpeakerVolumeStepSize(
|
| int32_t AudioMixerManagerLinuxALSA::SpeakerVolumeIsAvailable(
|
| bool& available)
|
| {
|
| - if (_outputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable output mixer element exists");
|
| - return -1;
|
| + if (_outputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable output mixer element exists");
|
| + return -1;
|
| }
|
|
|
| available = LATE(snd_mixer_selem_has_playback_volume)(_outputMixerElement);
|
| @@ -624,11 +590,10 @@ int32_t AudioMixerManagerLinuxALSA::SpeakerVolumeIsAvailable(
|
| int32_t AudioMixerManagerLinuxALSA::SpeakerMuteIsAvailable(
|
| bool& available)
|
| {
|
| - if (_outputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable output mixer element exists");
|
| - return -1;
|
| + if (_outputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable output mixer element exists");
|
| + return -1;
|
| }
|
|
|
| available = LATE(snd_mixer_selem_has_playback_switch)(_outputMixerElement);
|
| @@ -644,11 +609,10 @@ int32_t AudioMixerManagerLinuxALSA::SetSpeakerMute(bool enable)
|
|
|
| CriticalSectionScoped lock(&_critSect);
|
|
|
| - if (_outputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable output mixer element exists");
|
| - return -1;
|
| + if (_outputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable output mixer element exists");
|
| + return -1;
|
| }
|
|
|
| // Ensure that the selected speaker destination has a valid mute control.
|
| @@ -678,12 +642,10 @@ int32_t AudioMixerManagerLinuxALSA::SetSpeakerMute(bool enable)
|
|
|
| int32_t AudioMixerManagerLinuxALSA::SpeakerMute(bool& enabled) const
|
| {
|
| -
|
| - if (_outputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable output mixer exists");
|
| - return -1;
|
| + if (_outputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable output mixer exists");
|
| + return -1;
|
| }
|
|
|
| // Ensure that the selected speaker destination has a valid mute control.
|
| @@ -722,11 +684,10 @@ int32_t AudioMixerManagerLinuxALSA::SpeakerMute(bool& enabled) const
|
| int32_t AudioMixerManagerLinuxALSA::MicrophoneMuteIsAvailable(
|
| bool& available)
|
| {
|
| - if (_inputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer element exists");
|
| - return -1;
|
| + if (_inputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer element exists");
|
| + return -1;
|
| }
|
|
|
| available = LATE(snd_mixer_selem_has_capture_switch)(_inputMixerElement);
|
| @@ -741,11 +702,10 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneMute(bool enable)
|
|
|
| CriticalSectionScoped lock(&_critSect);
|
|
|
| - if (_inputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer element exists");
|
| - return -1;
|
| + if (_inputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer element exists");
|
| + return -1;
|
| }
|
|
|
| // Ensure that the selected microphone destination has a valid mute control.
|
| @@ -775,12 +735,10 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneMute(bool enable)
|
|
|
| int32_t AudioMixerManagerLinuxALSA::MicrophoneMute(bool& enabled) const
|
| {
|
| -
|
| - if (_inputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer exists");
|
| - return -1;
|
| + if (_inputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer exists");
|
| + return -1;
|
| }
|
|
|
| // Ensure that the selected microphone destination has a valid mute control.
|
| @@ -819,11 +777,10 @@ int32_t AudioMixerManagerLinuxALSA::MicrophoneMute(bool& enabled) const
|
| int32_t AudioMixerManagerLinuxALSA::MicrophoneBoostIsAvailable(
|
| bool& available)
|
| {
|
| - if (_inputMixerHandle == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer exists");
|
| - return -1;
|
| + if (_inputMixerHandle == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer exists");
|
| + return -1;
|
| }
|
|
|
| // Microphone boost cannot be enabled through ALSA Simple Mixer Interface
|
| @@ -840,11 +797,10 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneBoost(bool enable)
|
|
|
| CriticalSectionScoped lock(&_critSect);
|
|
|
| - if (_inputMixerHandle == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer exists");
|
| - return -1;
|
| + if (_inputMixerHandle == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer exists");
|
| + return -1;
|
| }
|
|
|
| // Ensure that the selected microphone destination has a valid mute control.
|
| @@ -864,12 +820,10 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneBoost(bool enable)
|
|
|
| int32_t AudioMixerManagerLinuxALSA::MicrophoneBoost(bool& enabled) const
|
| {
|
| -
|
| - if (_inputMixerHandle == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer exists");
|
| - return -1;
|
| + if (_inputMixerHandle == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer exists");
|
| + return -1;
|
| }
|
|
|
| // Microphone boost cannot be enabled on this platform!
|
| @@ -881,11 +835,10 @@ int32_t AudioMixerManagerLinuxALSA::MicrophoneBoost(bool& enabled) const
|
| int32_t AudioMixerManagerLinuxALSA::MicrophoneVolumeIsAvailable(
|
| bool& available)
|
| {
|
| - if (_inputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer element exists");
|
| - return -1;
|
| + if (_inputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer element exists");
|
| + return -1;
|
| }
|
|
|
| available = LATE(snd_mixer_selem_has_capture_volume)(_inputMixerElement);
|
| @@ -902,11 +855,10 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneVolume(
|
|
|
| CriticalSectionScoped lock(&_critSect);
|
|
|
| - if (_inputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer element exists");
|
| - return -1;
|
| + if (_inputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer element exists");
|
| + return -1;
|
| }
|
|
|
| int
|
| @@ -935,7 +887,7 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneVolume(
|
| uint32_t maxVolume)
|
| {
|
|
|
| - if (_inputMixerElement == NULL)
|
| + if (_inputMixerElement == nullptr)
|
| {
|
| WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| " no avaliable output mixer element exists");
|
| @@ -955,7 +907,8 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneVolume(
|
|
|
| maxVol = (long int)maxVolume;
|
| printf("min %d max %d", minVol, maxVol);
|
| - errVal = snd_mixer_selem_set_capture_volume_range(_inputMixerElement, minVol, maxVol);
|
| + errVal = snd_mixer_selem_set_capture_volume_range(_inputMixerElement, minVol,
|
| + maxVol);
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| " Capture hardware volume range, min: %d, max: %d", minVol, maxVol);
|
| if (errVal != 0)
|
| @@ -976,7 +929,7 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneVolume(
|
| uint32_t minVolume)
|
| {
|
|
|
| - if (_inputMixerElement == NULL)
|
| + if (_inputMixerElement == nullptr)
|
| {
|
| WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| " no avaliable output mixer element exists");
|
| @@ -1015,12 +968,10 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneVolume(
|
| int32_t AudioMixerManagerLinuxALSA::MicrophoneVolume(
|
| uint32_t& volume) const
|
| {
|
| -
|
| - if (_inputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer element exists");
|
| - return -1;
|
| + if (_inputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer element exists");
|
| + return -1;
|
| }
|
|
|
| long int vol(0);
|
| @@ -1050,12 +1001,10 @@ int32_t AudioMixerManagerLinuxALSA::MicrophoneVolume(
|
| int32_t AudioMixerManagerLinuxALSA::MaxMicrophoneVolume(
|
| uint32_t& maxVolume) const
|
| {
|
| -
|
| - if (_inputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer element exists");
|
| - return -1;
|
| + if (_inputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer element exists");
|
| + return -1;
|
| }
|
|
|
| long int minVol(0);
|
| @@ -1091,12 +1040,10 @@ int32_t AudioMixerManagerLinuxALSA::MaxMicrophoneVolume(
|
| int32_t AudioMixerManagerLinuxALSA::MinMicrophoneVolume(
|
| uint32_t& minVolume) const
|
| {
|
| -
|
| - if (_inputMixerElement == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer element exists");
|
| - return -1;
|
| + if (_inputMixerElement == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer element exists");
|
| + return -1;
|
| }
|
|
|
| long int minVol(0);
|
| @@ -1124,12 +1071,10 @@ int32_t AudioMixerManagerLinuxALSA::MinMicrophoneVolume(
|
| int32_t AudioMixerManagerLinuxALSA::MicrophoneVolumeStepSize(
|
| uint16_t& stepSize) const
|
| {
|
| -
|
| - if (_inputMixerHandle == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| - " no avaliable input mixer exists");
|
| - return -1;
|
| + if (_inputMixerHandle == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + " no avaliable input mixer exists");
|
| + return -1;
|
| }
|
|
|
| // The step size is always 1 for ALSA
|
| @@ -1150,14 +1095,14 @@ int32_t AudioMixerManagerLinuxALSA::LoadMicMixerElement() const
|
| WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| "snd_mixer_load(_inputMixerHandle), error: %s",
|
| LATE(snd_strerror)(errVal));
|
| - _inputMixerHandle = NULL;
|
| + _inputMixerHandle = nullptr;
|
| return -1;
|
| }
|
|
|
| - snd_mixer_elem_t *elem = NULL;
|
| - snd_mixer_elem_t *micElem = NULL;
|
| + snd_mixer_elem_t* elem = nullptr;
|
| + snd_mixer_elem_t* micElem = nullptr;
|
| unsigned mixerIdx = 0;
|
| - const char *selemName = NULL;
|
| + const char* selemName = nullptr;
|
|
|
| // Find and store handles to the right mixer elements
|
| for (elem = LATE(snd_mixer_first_elem)(_inputMixerHandle); elem; elem
|
| @@ -1187,22 +1132,19 @@ int32_t AudioMixerManagerLinuxALSA::LoadMicMixerElement() const
|
| }
|
| }
|
|
|
| - if (_inputMixerElement == NULL)
|
| - {
|
| - // We didn't find a Capture handle, use Mic.
|
| - if (micElem != NULL)
|
| - {
|
| - _inputMixerElement = micElem;
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - " Using Mic as capture volume.");
|
| - } else
|
| - {
|
| - _inputMixerElement = NULL;
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - "Could not find capture volume on the mixer.");
|
| + if (_inputMixerElement == nullptr) {
|
| + // We didn't find a Capture handle, use Mic.
|
| + if (micElem != nullptr) {
|
| + _inputMixerElement = micElem;
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + " Using Mic as capture volume.");
|
| + } else {
|
| + _inputMixerElement = nullptr;
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + "Could not find capture volume on the mixer.");
|
|
|
| - return -1;
|
| - }
|
| + return -1;
|
| + }
|
| }
|
|
|
| return 0;
|
| @@ -1216,15 +1158,15 @@ int32_t AudioMixerManagerLinuxALSA::LoadSpeakerMixerElement() const
|
| WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| " snd_mixer_load(_outputMixerHandle), error: %s",
|
| LATE(snd_strerror)(errVal));
|
| - _outputMixerHandle = NULL;
|
| + _outputMixerHandle = nullptr;
|
| return -1;
|
| }
|
|
|
| - snd_mixer_elem_t *elem = NULL;
|
| - snd_mixer_elem_t *masterElem = NULL;
|
| - snd_mixer_elem_t *speakerElem = NULL;
|
| + snd_mixer_elem_t* elem = nullptr;
|
| + snd_mixer_elem_t* masterElem = nullptr;
|
| + snd_mixer_elem_t* speakerElem = nullptr;
|
| unsigned mixerIdx = 0;
|
| - const char *selemName = NULL;
|
| + const char* selemName = nullptr;
|
|
|
| // Find and store handles to the right mixer elements
|
| for (elem = LATE(snd_mixer_first_elem)(_outputMixerHandle); elem; elem
|
| @@ -1264,25 +1206,21 @@ int32_t AudioMixerManagerLinuxALSA::LoadSpeakerMixerElement() const
|
| }
|
|
|
| // If we didn't find a PCM Handle, use Master or Speaker
|
| - if (_outputMixerElement == NULL)
|
| - {
|
| - if (masterElem != NULL)
|
| - {
|
| - _outputMixerElement = masterElem;
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - " Using Master as output volume.");
|
| - } else if (speakerElem != NULL)
|
| - {
|
| - _outputMixerElement = speakerElem;
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| - " Using Speaker as output volume.");
|
| - } else
|
| - {
|
| - _outputMixerElement = NULL;
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| - "Could not find output volume in the mixer.");
|
| - return -1;
|
| - }
|
| + if (_outputMixerElement == nullptr) {
|
| + if (masterElem != nullptr) {
|
| + _outputMixerElement = masterElem;
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + " Using Master as output volume.");
|
| + } else if (speakerElem != nullptr) {
|
| + _outputMixerElement = speakerElem;
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + " Using Speaker as output volume.");
|
| + } else {
|
| + _outputMixerElement = nullptr;
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + "Could not find output volume in the mixer.");
|
| + return -1;
|
| + }
|
| }
|
|
|
| return 0;
|
|
|