Tidying to match the Web SDK

This commit is contained in:
David Rowe 2021-10-01 09:09:07 +13:00
parent 6c4e105c06
commit de37734e18
2 changed files with 12 additions and 13 deletions

View file

@ -942,7 +942,7 @@ void AudioClient::Gate::flush() {
void AudioClient::handleNoisyMutePacket(QSharedPointer<ReceivedMessage> message) { void AudioClient::handleNoisyMutePacket(QSharedPointer<ReceivedMessage> message) {
if (!_muted) { if (!_isMuted) {
setMuted(true); setMuted(true);
// have the audio scripting interface emit a signal to say we were muted by the mixer // 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; _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... // release any old codec encoder/decoder first...
if (_codec && _encoder) { if (_codec && _encoder) {
@ -1005,7 +1005,7 @@ void AudioClient::selectAudioFormat(const QString& selectedCodecName) {
_codec = plugin; _codec = plugin;
_receivedAudioStream.setupCodec(plugin, _selectedCodecName, AudioConstants::STEREO); _receivedAudioStream.setupCodec(plugin, _selectedCodecName, AudioConstants::STEREO);
_encoder = plugin->createEncoder(AudioConstants::SAMPLE_RATE, _isStereoInput ? AudioConstants::STEREO : AudioConstants::MONO); _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; break;
} }
} }
@ -1269,7 +1269,7 @@ void AudioClient::processWebrtcNearEnd(int16_t* samples, int numFrames, int numC
void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) { 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. // 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(); bool hasReverb = _reverb || _receivedAudioStream.hasReverb();
if ((_muted && !_shouldEchoLocally) || !_audioOutput || (!_shouldEchoLocally && !hasReverb) || !_audioGateOpen) { if ((_isMuted && !_shouldEchoLocally) || !_audioOutput || (!_shouldEchoLocally && !hasReverb) || !_audioGateOpen) {
return; return;
} }
@ -1357,7 +1357,7 @@ void AudioClient::handleAudioInput(QByteArray& audioBuffer) {
bool audioGateOpen = false; bool audioGateOpen = false;
if (!_muted) { if (!_isMuted) {
int16_t* samples = reinterpret_cast<int16_t*>(audioBuffer.data()); int16_t* samples = reinterpret_cast<int16_t*>(audioBuffer.data());
int numSamples = audioBuffer.size() / AudioConstants::SAMPLE_SIZE; int numSamples = audioBuffer.size() / AudioConstants::SAMPLE_SIZE;
int numFrames = numSamples / (_isStereoInput ? AudioConstants::STEREO : AudioConstants::MONO); int numFrames = numSamples / (_isStereoInput ? AudioConstants::STEREO : AudioConstants::MONO);
@ -1378,7 +1378,7 @@ void AudioClient::handleAudioInput(QByteArray& audioBuffer) {
} }
// loudness after mute/gate // loudness after mute/gate
_lastInputLoudness = (_muted || !audioGateOpen) ? 0.0f : _lastRawInputLoudness; _lastInputLoudness = (_isMuted || !audioGateOpen) ? 0.0f : _lastRawInputLoudness;
// detect gate opening and closing // detect gate opening and closing
bool openedInLastBlock = !_audioGateOpen && audioGateOpen; // the gate just opened bool openedInLastBlock = !_audioGateOpen && audioGateOpen; // the gate just opened
@ -1482,7 +1482,7 @@ void AudioClient::handleMicAudioInput() {
emit inputLoudnessChanged(_lastSmoothedRawInputLoudness, isClipping); emit inputLoudnessChanged(_lastSmoothedRawInputLoudness, isClipping);
if (!_muted) { if (!_isMuted) {
possibleResampling(_inputToNetworkResampler, possibleResampling(_inputToNetworkResampler,
inputAudioSamples.get(), networkAudioSamples, inputAudioSamples.get(), networkAudioSamples,
inputSamplesRequired, numNetworkSamples, inputSamplesRequired, numNetworkSamples,
@ -1748,10 +1748,10 @@ void AudioClient::sendMuteEnvironmentPacket() {
} }
void AudioClient::setMuted(bool muted, bool emitSignal) { void AudioClient::setMuted(bool muted, bool emitSignal) {
if (_muted != muted) { if (_isMuted != muted) {
_muted = muted; _isMuted = muted;
if (emitSignal) { if (emitSignal) {
emit muteToggled(_muted); emit muteToggled(_isMuted);
} }
} }
} }
@ -1896,7 +1896,6 @@ bool AudioClient::switchInputToAudioDevice(const HifiAudioDeviceInfo inputDevice
if (_dummyAudioInput) { if (_dummyAudioInput) {
_dummyAudioInput->stop(); _dummyAudioInput->stop();
_dummyAudioInput->deleteLater(); _dummyAudioInput->deleteLater();
_dummyAudioInput = NULL; _dummyAudioInput = NULL;
} }

View file

@ -217,7 +217,7 @@ public slots:
void audioMixerKilled(); void audioMixerKilled();
void setMuted(bool muted, bool emitSignal = true); void setMuted(bool muted, bool emitSignal = true);
bool isMuted() { return _muted; } bool isMuted() { return _isMuted; }
virtual bool setIsStereoInput(bool stereo) override; virtual bool setIsStereoInput(bool stereo) override;
virtual bool isStereoInput() override { return _isStereoInput; } virtual bool isStereoInput() override { return _isStereoInput; }
@ -410,7 +410,7 @@ private:
float _timeSinceLastClip{ -1.0f }; float _timeSinceLastClip{ -1.0f };
int _totalInputAudioSamples; int _totalInputAudioSamples;
bool _muted{ false }; bool _isMuted{ false };
bool _shouldEchoLocally{ false }; bool _shouldEchoLocally{ false };
bool _shouldEchoToServer{ false }; bool _shouldEchoToServer{ false };
bool _isNoiseGateEnabled{ true }; bool _isNoiseGateEnabled{ true };