Fixed mute handling and audio LED

* AFV client has own "changedMute" signal
* unmute if started/stopped AFC client
* in statusbar also check audio start/stop to refresh LEDs
* see https://discordapp.com/channels/539048679160676382/539486309882789888/713491666971000872
This commit is contained in:
Klaus Basan
2020-05-23 01:18:59 +02:00
committed by Mat Sutcliffe
parent 24bc57ac32
commit 6fc3d55d9a
5 changed files with 56 additions and 17 deletions

View File

@@ -273,7 +273,10 @@ namespace BlackCore
void CAfvClient::setMuted(bool mute)
{
if (this->isMuted() == mute) { return; }
this->setNormalizedOutputVolume(mute ? 0 : 50);
emit this->changedMute(mute);
}
void CAfvClient::startAudio()
@@ -352,6 +355,13 @@ namespace BlackCore
this->onTimerUpdate(); // update values
emit this->startedAudio(useInputDevice, useOutputDevice);
if (this->isMuted())
{
// un-mute after startup
this->setMuted(false);
}
}
void CAfvClient::startAudio(const QString &inputDeviceName, const QString &outputDeviceName)
@@ -388,6 +398,8 @@ namespace BlackCore
}
CLogMessage(this).info(u"AFV Client stopped");
if (this->isMuted()) { this->setMuted(false); }
emit this->inputVolumePeakVU(0.0);
emit this->outputVolumePeakVU(0.0);
emit this->stoppedAudio();

View File

@@ -313,6 +313,9 @@ namespace BlackCore
//! Audio has been stopped
void stoppedAudio();
//! Mute changed
void changedMute(bool muted);
protected:
//! \copydoc BlackMisc::CContinuousWorker::initialize
virtual void initialize() override;

View File

@@ -207,6 +207,7 @@ namespace BlackCore
connect(m_voiceClient, &CAfvClient::startedAudio, this, &CContextAudioBase::startedAudio, Qt::QueuedConnection);
connect(m_voiceClient, &CAfvClient::stoppedAudio, this, &CContextAudioBase::stoppedAudio, Qt::QueuedConnection);
connect(m_voiceClient, &CAfvClient::ptt, this, &CContextAudioBase::ptt, Qt::QueuedConnection);
connect(m_voiceClient, &CAfvClient::changedMute, this, &CContextAudioBase::changedMute, Qt::QueuedConnection);
connect(m_voiceClient, &CAfvClient::connectionStatusChanged, this, &CContextAudioBase::onAfvConnectionStatusChanged, Qt::QueuedConnection);
connect(m_voiceClient, &CAfvClient::afvConnectionFailure, this, &CContextAudioBase::onAfvConnectionFailure, Qt::QueuedConnection);
}
@@ -429,6 +430,7 @@ namespace BlackCore
const bool changedVoiceOutput = (currentVolume != volume);
if (changedVoiceOutput)
{
// TODO: KB 2020-05 the mute handling should entirely go to AFV client!
m_voiceClient->setNormalizedOutputVolume(volume);
m_outVolumeBeforeMute = volume;
@@ -468,8 +470,8 @@ namespace BlackCore
m_voiceClient->setMuted(muted);
if (!muted) { m_voiceClient->setNormalizedOutputVolume(m_outVolumeBeforeMute); }
// signal
emit this->changedMute(muted);
// signal no longer need, signaled by m_voiceClient->setMuted
// emit this->changedMute(muted);
}
bool CContextAudioBase::isMuted() const
@@ -503,13 +505,13 @@ namespace BlackCore
if (!play) { return; }
if (notification == CNotificationSounds::PTTClickKeyDown && (considerSettings && settings.noAudioTransmission()))
{
/**
/*
if (!this->canTalk())
{
// warning sound
notification = CNotificationSounds::NotificationNoAudioTransmission;
}
**/
*/
}
if (volume < 0 || volume > 100)