mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 18:25:37 +08:00
refactor(afv): Clarify that mute is for output
This commit is contained in:
@@ -251,17 +251,17 @@ namespace BlackCore::Afv::Clients
|
||||
}
|
||||
}
|
||||
|
||||
bool CAfvClient::isMuted() const
|
||||
bool CAfvClient::isOutputMuted() const
|
||||
{
|
||||
const int v = this->getNormalizedMasterOutputVolume();
|
||||
return v < 1;
|
||||
}
|
||||
|
||||
void CAfvClient::setMuted(bool mute)
|
||||
void CAfvClient::setOutputMuted(bool mute)
|
||||
{
|
||||
if (this->isMuted() == mute) { return; }
|
||||
if (this->isOutputMuted() == mute) { return; }
|
||||
this->setNormalizedMasterOutputVolume(mute ? 0 : 50);
|
||||
emit this->changedMute(mute);
|
||||
emit this->changedOutputMute(mute);
|
||||
}
|
||||
|
||||
void CAfvClient::startAudio()
|
||||
@@ -339,10 +339,10 @@ namespace BlackCore::Afv::Clients
|
||||
|
||||
emit this->startedAudio(useInputDevice, useOutputDevice);
|
||||
|
||||
if (this->isMuted())
|
||||
if (this->isOutputMuted())
|
||||
{
|
||||
// un-mute after startup
|
||||
this->setMuted(false);
|
||||
this->setOutputMuted(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace BlackCore::Afv::Clients
|
||||
}
|
||||
CLogMessage(this).info(u"AFV Client stopped");
|
||||
|
||||
if (this->isMuted()) { this->setMuted(false); }
|
||||
if (this->isOutputMuted()) { this->setOutputMuted(false); }
|
||||
|
||||
emit this->inputVolumePeakVU(0.0);
|
||||
emit this->outputVolumePeakVU(0.0);
|
||||
|
||||
@@ -108,10 +108,10 @@ namespace BlackCore::Afv::Clients
|
||||
bool isStarted() const { return m_isStarted; }
|
||||
|
||||
//! @{
|
||||
//! Muted
|
||||
//! Muted (output)
|
||||
//! \threadsafe
|
||||
bool isMuted() const;
|
||||
void setMuted(bool mute);
|
||||
bool isOutputMuted() const;
|
||||
void setOutputMuted(bool mute);
|
||||
//! @}
|
||||
|
||||
//! @{
|
||||
@@ -308,8 +308,8 @@ namespace BlackCore::Afv::Clients
|
||||
//! Audio has been stopped
|
||||
void stoppedAudio();
|
||||
|
||||
//! Mute changed
|
||||
void changedMute(bool muted);
|
||||
//! Output mute changed
|
||||
void changedOutputMute(bool muted);
|
||||
|
||||
protected:
|
||||
//! \copydoc BlackMisc::CContinuousWorker::initialize
|
||||
|
||||
@@ -87,12 +87,12 @@ namespace BlackCore::Context
|
||||
|
||||
if (parser.matchesCommand(".mute"))
|
||||
{
|
||||
this->setMute(true);
|
||||
this->setOutputMute(true);
|
||||
return true;
|
||||
}
|
||||
else if (parser.matchesCommand(".unmute"))
|
||||
{
|
||||
this->setMute(false);
|
||||
this->setOutputMute(false);
|
||||
return true;
|
||||
}
|
||||
else if (parser.commandStartsWith("vol") && parser.countParts() > 1)
|
||||
@@ -193,7 +193,7 @@ namespace BlackCore::Context
|
||||
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::changedOutputMute, this, &CContextAudioBase::changedOutputMute, Qt::QueuedConnection);
|
||||
connect(m_voiceClient, &CAfvClient::connectionStatusChanged, this, &CContextAudioBase::onAfvConnectionStatusChanged, Qt::QueuedConnection);
|
||||
connect(m_voiceClient, &CAfvClient::afvConnectionFailure, this, &CContextAudioBase::onAfvConnectionFailure, Qt::QueuedConnection);
|
||||
}
|
||||
@@ -405,7 +405,7 @@ namespace BlackCore::Context
|
||||
{
|
||||
if (!m_voiceClient) { return; }
|
||||
|
||||
const bool wasMuted = this->isMuted();
|
||||
const bool wasMuted = this->isOutputMuted();
|
||||
volume = CSettings::fixOutVolume(volume);
|
||||
|
||||
const int currentVolume = m_voiceClient->getNormalizedMasterOutputVolume();
|
||||
@@ -420,7 +420,7 @@ namespace BlackCore::Context
|
||||
if ((volume > 0 && wasMuted) || (volume < 1 && !wasMuted))
|
||||
{
|
||||
// inform about muted
|
||||
emit this->changedMute(volume < 1);
|
||||
emit this->changedOutputMute(volume < 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,24 +472,24 @@ namespace BlackCore::Context
|
||||
return m_voiceClient->getNormalizedComOutputVolume(comUnit);
|
||||
}
|
||||
|
||||
void CContextAudioBase::setMute(bool muted)
|
||||
void CContextAudioBase::setOutputMute(bool muted)
|
||||
{
|
||||
if (!m_voiceClient) { return; }
|
||||
if (this->isMuted() == muted) { return; } // avoid roundtrips / unnecessary signals
|
||||
if (this->isOutputMuted() == muted) { return; } // avoid roundtrips / unnecessary signals
|
||||
|
||||
if (muted) { m_outMasterVolumeBeforeMute = m_voiceClient->getNormalizedMasterOutputVolume(); }
|
||||
|
||||
m_voiceClient->setMuted(muted);
|
||||
m_voiceClient->setOutputMuted(muted);
|
||||
if (!muted) { m_voiceClient->setNormalizedMasterOutputVolume(m_outMasterVolumeBeforeMute); }
|
||||
|
||||
// signal no longer need, signaled by m_voiceClient->setMuted
|
||||
// emit this->changedMute(muted);
|
||||
}
|
||||
|
||||
bool CContextAudioBase::isMuted() const
|
||||
bool CContextAudioBase::isOutputMuted() const
|
||||
{
|
||||
if (!m_voiceClient) { return false; }
|
||||
return m_voiceClient->isMuted();
|
||||
return m_voiceClient->isOutputMuted();
|
||||
}
|
||||
|
||||
void CContextAudioBase::playSelcalTone(const CSelcal &selcal)
|
||||
|
||||
@@ -178,8 +178,8 @@ namespace BlackCore
|
||||
void setComOutputVolume(BlackMisc::Aviation::CComSystem::ComUnit comUnit, int volume);
|
||||
int getMasterOutputVolume() const;
|
||||
int getComOutputVolume(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
|
||||
void setMute(bool muted);
|
||||
bool isMuted() const;
|
||||
void setOutputMute(bool muted);
|
||||
bool isOutputMuted() const;
|
||||
//! @}
|
||||
|
||||
//! SELCAL
|
||||
@@ -266,8 +266,8 @@ namespace BlackCore
|
||||
//! \sa setVoiceOutputVolume
|
||||
void changedAudioVolume(int volume);
|
||||
|
||||
//! Mute changed
|
||||
void changedMute(bool muted);
|
||||
//! Output mute changed
|
||||
void changedOutputMute(bool muted);
|
||||
|
||||
//! Changed audio devices (e.g. device enabled/disable)
|
||||
void changedLocalAudioDevices(const BlackMisc::Audio::CAudioDeviceInfoList &devices);
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace BlackCore::Context
|
||||
"changedAudioVolume", this, SIGNAL(changedAudioVolume(int)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||
"changedMute", this, SIGNAL(changedMute(bool)));
|
||||
"changedOutputMute", this, SIGNAL(changedOutputMute(bool)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||
"changedLocalAudioDevices", this, SIGNAL(changedLocalAudioDevices(BlackMisc::Audio::CAudioDeviceInfoList)));
|
||||
|
||||
Reference in New Issue
Block a user