From de37734e18356d75a015822b6bf595470bf8d7d8 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 1 Oct 2021 09:09:07 +1300 Subject: [PATCH] Tidying to match the Web SDK --- libraries/audio-client/src/AudioClient.cpp | 21 ++++++++++----------- libraries/audio-client/src/AudioClient.h | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index c25dd61f68..285549734c 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -942,7 +942,7 @@ void AudioClient::Gate::flush() { void AudioClient::handleNoisyMutePacket(QSharedPointer message) { - if (!_muted) { + if (!_isMuted) { setMuted(true); // have the audio scripting interface emit a signal to say we were muted by the mixer @@ -989,7 +989,7 @@ void AudioClient::selectAudioFormat(const QString& selectedCodecName) { _selectedCodecName = selectedCodecName; - qCDebug(audioclient) << "Selected Codec:" << _selectedCodecName << "isStereoInput:" << _isStereoInput; + qCDebug(audioclient) << "Selected codec:" << _selectedCodecName << "; Is stereo input:" << _isStereoInput; // release any old codec encoder/decoder first... if (_codec && _encoder) { @@ -1005,7 +1005,7 @@ void AudioClient::selectAudioFormat(const QString& selectedCodecName) { _codec = plugin; _receivedAudioStream.setupCodec(plugin, _selectedCodecName, AudioConstants::STEREO); _encoder = plugin->createEncoder(AudioConstants::SAMPLE_RATE, _isStereoInput ? AudioConstants::STEREO : AudioConstants::MONO); - qCDebug(audioclient) << "Selected Codec Plugin:" << _codec.get(); + qCDebug(audioclient) << "Selected codec plugin:" << _codec.get(); break; } } @@ -1269,7 +1269,7 @@ void AudioClient::processWebrtcNearEnd(int16_t* samples, int numFrames, int numC void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) { // If there is server echo, reverb will be applied to the recieved audio stream so no need to have it here. bool hasReverb = _reverb || _receivedAudioStream.hasReverb(); - if ((_muted && !_shouldEchoLocally) || !_audioOutput || (!_shouldEchoLocally && !hasReverb) || !_audioGateOpen) { + if ((_isMuted && !_shouldEchoLocally) || !_audioOutput || (!_shouldEchoLocally && !hasReverb) || !_audioGateOpen) { return; } @@ -1357,7 +1357,7 @@ void AudioClient::handleAudioInput(QByteArray& audioBuffer) { bool audioGateOpen = false; - if (!_muted) { + if (!_isMuted) { int16_t* samples = reinterpret_cast(audioBuffer.data()); int numSamples = audioBuffer.size() / AudioConstants::SAMPLE_SIZE; int numFrames = numSamples / (_isStereoInput ? AudioConstants::STEREO : AudioConstants::MONO); @@ -1378,7 +1378,7 @@ void AudioClient::handleAudioInput(QByteArray& audioBuffer) { } // loudness after mute/gate - _lastInputLoudness = (_muted || !audioGateOpen) ? 0.0f : _lastRawInputLoudness; + _lastInputLoudness = (_isMuted || !audioGateOpen) ? 0.0f : _lastRawInputLoudness; // detect gate opening and closing bool openedInLastBlock = !_audioGateOpen && audioGateOpen; // the gate just opened @@ -1482,7 +1482,7 @@ void AudioClient::handleMicAudioInput() { emit inputLoudnessChanged(_lastSmoothedRawInputLoudness, isClipping); - if (!_muted) { + if (!_isMuted) { possibleResampling(_inputToNetworkResampler, inputAudioSamples.get(), networkAudioSamples, inputSamplesRequired, numNetworkSamples, @@ -1748,10 +1748,10 @@ void AudioClient::sendMuteEnvironmentPacket() { } void AudioClient::setMuted(bool muted, bool emitSignal) { - if (_muted != muted) { - _muted = muted; + if (_isMuted != muted) { + _isMuted = muted; if (emitSignal) { - emit muteToggled(_muted); + emit muteToggled(_isMuted); } } } @@ -1896,7 +1896,6 @@ bool AudioClient::switchInputToAudioDevice(const HifiAudioDeviceInfo inputDevice if (_dummyAudioInput) { _dummyAudioInput->stop(); - _dummyAudioInput->deleteLater(); _dummyAudioInput = NULL; } diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index c414d74b6a..51e0ecd2ee 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -217,7 +217,7 @@ public slots: void audioMixerKilled(); void setMuted(bool muted, bool emitSignal = true); - bool isMuted() { return _muted; } + bool isMuted() { return _isMuted; } virtual bool setIsStereoInput(bool stereo) override; virtual bool isStereoInput() override { return _isStereoInput; } @@ -410,7 +410,7 @@ private: float _timeSinceLastClip{ -1.0f }; int _totalInputAudioSamples; - bool _muted{ false }; + bool _isMuted{ false }; bool _shouldEchoLocally{ false }; bool _shouldEchoToServer{ false }; bool _isNoiseGateEnabled{ true };