mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +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)));
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace BlackGui::Components
|
||||
ui->led_Audio->setOn(CInfoBarStatusComponent::isAudioAvailableAndNotMuted());
|
||||
if (sGui->getCContextAudioBase())
|
||||
{
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedMute, this, &CInfoBarStatusComponent::onMuteChanged, Qt::QueuedConnection);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedOutputMute, this, &CInfoBarStatusComponent::onOutputMuteChanged, Qt::QueuedConnection);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::startedAudio, this, &CInfoBarStatusComponent::onAudioStarted, Qt::QueuedConnection);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::stoppedAudio, this, &CInfoBarStatusComponent::onAudioStopped, Qt::QueuedConnection);
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace BlackGui::Components
|
||||
if (selectedItem == actions.at(0))
|
||||
{
|
||||
// toggle MUTED
|
||||
sGui->getCContextAudioBase()->setMute(!sGui->getCContextAudioBase()->isMuted());
|
||||
sGui->getCContextAudioBase()->setOutputMute(!sGui->getCContextAudioBase()->isOutputMuted());
|
||||
}
|
||||
else if (actions.size() > 1 && selectedItem == actions.at(1))
|
||||
{
|
||||
@@ -228,7 +228,7 @@ namespace BlackGui::Components
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::onMuteChanged(bool muted)
|
||||
void CInfoBarStatusComponent::onOutputMuteChanged(bool muted)
|
||||
{
|
||||
const bool on = !muted && isAudioAvailableAndNotMuted(); // make sure audio is started
|
||||
ui->led_Audio->setOn(on);
|
||||
@@ -311,6 +311,6 @@ namespace BlackGui::Components
|
||||
{
|
||||
if (!sGui || !sGui->getCContextAudioBase() || sGui->isShuttingDown()) { return false; }
|
||||
if (!sGui->getCContextAudioBase()->isAudioStarted()) { return false; }
|
||||
return !sGui->getCContextAudioBase()->isMuted();
|
||||
return !sGui->getCContextAudioBase()->isOutputMuted();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -79,8 +79,8 @@ namespace BlackGui::Components
|
||||
//! Context menu requested
|
||||
void onCustomAudioContextMenuRequested(const QPoint &position);
|
||||
|
||||
//! Mute changed
|
||||
void onMuteChanged(bool muted);
|
||||
//! Output mute changed
|
||||
void onOutputMuteChanged(bool muted);
|
||||
|
||||
//! Audio started
|
||||
void onAudioStarted(const BlackMisc::Audio::CAudioDeviceInfo &input, const BlackMisc::Audio::CAudioDeviceInfo &output);
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace BlackGui::Components
|
||||
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMainKeypadAreaComponent::connectionStatusChanged);
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ownAircraftCockpitChanged);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedMute, this, &CMainKeypadAreaComponent::muteChanged);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedOutputMute, this, &CMainKeypadAreaComponent::outputMuteChanged);
|
||||
connect(this, &CMainKeypadAreaComponent::commandEntered, sGui->getCoreFacade(), &CCoreFacade::parseCommandLine);
|
||||
|
||||
QPointer<CMainKeypadAreaComponent> myself(this);
|
||||
@@ -139,8 +139,8 @@ namespace BlackGui::Components
|
||||
}
|
||||
else if (senderButton == ui->pb_SoundMute && sGui->getIContextAudio())
|
||||
{
|
||||
const bool mute = sGui->getCContextAudioBase()->isMuted();
|
||||
sGui->getCContextAudioBase()->setMute(!mute);
|
||||
const bool mute = sGui->getCContextAudioBase()->isOutputMuted();
|
||||
sGui->getCContextAudioBase()->setOutputMute(!mute);
|
||||
}
|
||||
else if (senderButton == ui->pb_Connect)
|
||||
{
|
||||
@@ -184,7 +184,7 @@ namespace BlackGui::Components
|
||||
}
|
||||
}
|
||||
|
||||
void CMainKeypadAreaComponent::muteChanged(bool muted)
|
||||
void CMainKeypadAreaComponent::outputMuteChanged(bool muted)
|
||||
{
|
||||
// check state to avoid undelibarate signals
|
||||
if (muted != ui->pb_SoundMute->isChecked())
|
||||
@@ -257,7 +257,7 @@ namespace BlackGui::Components
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->supportsContexts()) { return; }
|
||||
if (sGui->getCContextAudioBase())
|
||||
{
|
||||
this->muteChanged(sGui->getCContextAudioBase()->isMuted());
|
||||
this->outputMuteChanged(sGui->getCContextAudioBase()->isOutputMuted());
|
||||
}
|
||||
this->updateConnectionStatus();
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ namespace BlackGui::Components
|
||||
//! \copydoc BlackCore::Context::IContextOwnAircraft::changedAircraftCockpit
|
||||
void ownAircraftCockpitChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
||||
|
||||
//! \copydoc BlackCore::Context::IContextAudio::changedMute
|
||||
void muteChanged(bool muted);
|
||||
//! \copydoc BlackCore::Context::IContextAudio::changedOutputMute
|
||||
void outputMuteChanged(bool muted);
|
||||
|
||||
//! If button is info area, identify it
|
||||
CMainInfoAreaComponent::InfoArea buttonToMainInfoArea(const QObject *button) const;
|
||||
|
||||
Reference in New Issue
Block a user