mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45: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();
|
const int v = this->getNormalizedMasterOutputVolume();
|
||||||
return v < 1;
|
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);
|
this->setNormalizedMasterOutputVolume(mute ? 0 : 50);
|
||||||
emit this->changedMute(mute);
|
emit this->changedOutputMute(mute);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::startAudio()
|
void CAfvClient::startAudio()
|
||||||
@@ -339,10 +339,10 @@ namespace BlackCore::Afv::Clients
|
|||||||
|
|
||||||
emit this->startedAudio(useInputDevice, useOutputDevice);
|
emit this->startedAudio(useInputDevice, useOutputDevice);
|
||||||
|
|
||||||
if (this->isMuted())
|
if (this->isOutputMuted())
|
||||||
{
|
{
|
||||||
// un-mute after startup
|
// 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");
|
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->inputVolumePeakVU(0.0);
|
||||||
emit this->outputVolumePeakVU(0.0);
|
emit this->outputVolumePeakVU(0.0);
|
||||||
|
|||||||
@@ -108,10 +108,10 @@ namespace BlackCore::Afv::Clients
|
|||||||
bool isStarted() const { return m_isStarted; }
|
bool isStarted() const { return m_isStarted; }
|
||||||
|
|
||||||
//! @{
|
//! @{
|
||||||
//! Muted
|
//! Muted (output)
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
bool isMuted() const;
|
bool isOutputMuted() const;
|
||||||
void setMuted(bool mute);
|
void setOutputMuted(bool mute);
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! @{
|
//! @{
|
||||||
@@ -308,8 +308,8 @@ namespace BlackCore::Afv::Clients
|
|||||||
//! Audio has been stopped
|
//! Audio has been stopped
|
||||||
void stoppedAudio();
|
void stoppedAudio();
|
||||||
|
|
||||||
//! Mute changed
|
//! Output mute changed
|
||||||
void changedMute(bool muted);
|
void changedOutputMute(bool muted);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \copydoc BlackMisc::CContinuousWorker::initialize
|
//! \copydoc BlackMisc::CContinuousWorker::initialize
|
||||||
|
|||||||
@@ -87,12 +87,12 @@ namespace BlackCore::Context
|
|||||||
|
|
||||||
if (parser.matchesCommand(".mute"))
|
if (parser.matchesCommand(".mute"))
|
||||||
{
|
{
|
||||||
this->setMute(true);
|
this->setOutputMute(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (parser.matchesCommand(".unmute"))
|
else if (parser.matchesCommand(".unmute"))
|
||||||
{
|
{
|
||||||
this->setMute(false);
|
this->setOutputMute(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (parser.commandStartsWith("vol") && parser.countParts() > 1)
|
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::startedAudio, this, &CContextAudioBase::startedAudio, Qt::QueuedConnection);
|
||||||
connect(m_voiceClient, &CAfvClient::stoppedAudio, this, &CContextAudioBase::stoppedAudio, 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::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::connectionStatusChanged, this, &CContextAudioBase::onAfvConnectionStatusChanged, Qt::QueuedConnection);
|
||||||
connect(m_voiceClient, &CAfvClient::afvConnectionFailure, this, &CContextAudioBase::onAfvConnectionFailure, Qt::QueuedConnection);
|
connect(m_voiceClient, &CAfvClient::afvConnectionFailure, this, &CContextAudioBase::onAfvConnectionFailure, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ namespace BlackCore::Context
|
|||||||
{
|
{
|
||||||
if (!m_voiceClient) { return; }
|
if (!m_voiceClient) { return; }
|
||||||
|
|
||||||
const bool wasMuted = this->isMuted();
|
const bool wasMuted = this->isOutputMuted();
|
||||||
volume = CSettings::fixOutVolume(volume);
|
volume = CSettings::fixOutVolume(volume);
|
||||||
|
|
||||||
const int currentVolume = m_voiceClient->getNormalizedMasterOutputVolume();
|
const int currentVolume = m_voiceClient->getNormalizedMasterOutputVolume();
|
||||||
@@ -420,7 +420,7 @@ namespace BlackCore::Context
|
|||||||
if ((volume > 0 && wasMuted) || (volume < 1 && !wasMuted))
|
if ((volume > 0 && wasMuted) || (volume < 1 && !wasMuted))
|
||||||
{
|
{
|
||||||
// inform about muted
|
// 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);
|
return m_voiceClient->getNormalizedComOutputVolume(comUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextAudioBase::setMute(bool muted)
|
void CContextAudioBase::setOutputMute(bool muted)
|
||||||
{
|
{
|
||||||
if (!m_voiceClient) { return; }
|
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(); }
|
if (muted) { m_outMasterVolumeBeforeMute = m_voiceClient->getNormalizedMasterOutputVolume(); }
|
||||||
|
|
||||||
m_voiceClient->setMuted(muted);
|
m_voiceClient->setOutputMuted(muted);
|
||||||
if (!muted) { m_voiceClient->setNormalizedMasterOutputVolume(m_outMasterVolumeBeforeMute); }
|
if (!muted) { m_voiceClient->setNormalizedMasterOutputVolume(m_outMasterVolumeBeforeMute); }
|
||||||
|
|
||||||
// signal no longer need, signaled by m_voiceClient->setMuted
|
// signal no longer need, signaled by m_voiceClient->setMuted
|
||||||
// emit this->changedMute(muted);
|
// emit this->changedMute(muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CContextAudioBase::isMuted() const
|
bool CContextAudioBase::isOutputMuted() const
|
||||||
{
|
{
|
||||||
if (!m_voiceClient) { return false; }
|
if (!m_voiceClient) { return false; }
|
||||||
return m_voiceClient->isMuted();
|
return m_voiceClient->isOutputMuted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextAudioBase::playSelcalTone(const CSelcal &selcal)
|
void CContextAudioBase::playSelcalTone(const CSelcal &selcal)
|
||||||
|
|||||||
@@ -178,8 +178,8 @@ namespace BlackCore
|
|||||||
void setComOutputVolume(BlackMisc::Aviation::CComSystem::ComUnit comUnit, int volume);
|
void setComOutputVolume(BlackMisc::Aviation::CComSystem::ComUnit comUnit, int volume);
|
||||||
int getMasterOutputVolume() const;
|
int getMasterOutputVolume() const;
|
||||||
int getComOutputVolume(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
|
int getComOutputVolume(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
|
||||||
void setMute(bool muted);
|
void setOutputMute(bool muted);
|
||||||
bool isMuted() const;
|
bool isOutputMuted() const;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! SELCAL
|
//! SELCAL
|
||||||
@@ -266,8 +266,8 @@ namespace BlackCore
|
|||||||
//! \sa setVoiceOutputVolume
|
//! \sa setVoiceOutputVolume
|
||||||
void changedAudioVolume(int volume);
|
void changedAudioVolume(int volume);
|
||||||
|
|
||||||
//! Mute changed
|
//! Output mute changed
|
||||||
void changedMute(bool muted);
|
void changedOutputMute(bool muted);
|
||||||
|
|
||||||
//! Changed audio devices (e.g. device enabled/disable)
|
//! Changed audio devices (e.g. device enabled/disable)
|
||||||
void changedLocalAudioDevices(const BlackMisc::Audio::CAudioDeviceInfoList &devices);
|
void changedLocalAudioDevices(const BlackMisc::Audio::CAudioDeviceInfoList &devices);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace BlackCore::Context
|
|||||||
"changedAudioVolume", this, SIGNAL(changedAudioVolume(int)));
|
"changedAudioVolume", this, SIGNAL(changedAudioVolume(int)));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||||
"changedMute", this, SIGNAL(changedMute(bool)));
|
"changedOutputMute", this, SIGNAL(changedOutputMute(bool)));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||||
"changedLocalAudioDevices", this, SIGNAL(changedLocalAudioDevices(BlackMisc::Audio::CAudioDeviceInfoList)));
|
"changedLocalAudioDevices", this, SIGNAL(changedLocalAudioDevices(BlackMisc::Audio::CAudioDeviceInfoList)));
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace BlackGui::Components
|
|||||||
ui->led_Audio->setOn(CInfoBarStatusComponent::isAudioAvailableAndNotMuted());
|
ui->led_Audio->setOn(CInfoBarStatusComponent::isAudioAvailableAndNotMuted());
|
||||||
if (sGui->getCContextAudioBase())
|
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::startedAudio, this, &CInfoBarStatusComponent::onAudioStarted, Qt::QueuedConnection);
|
||||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::stoppedAudio, this, &CInfoBarStatusComponent::onAudioStopped, Qt::QueuedConnection);
|
connect(sGui->getCContextAudioBase(), &CContextAudioBase::stoppedAudio, this, &CInfoBarStatusComponent::onAudioStopped, Qt::QueuedConnection);
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ namespace BlackGui::Components
|
|||||||
if (selectedItem == actions.at(0))
|
if (selectedItem == actions.at(0))
|
||||||
{
|
{
|
||||||
// toggle MUTED
|
// toggle MUTED
|
||||||
sGui->getCContextAudioBase()->setMute(!sGui->getCContextAudioBase()->isMuted());
|
sGui->getCContextAudioBase()->setOutputMute(!sGui->getCContextAudioBase()->isOutputMuted());
|
||||||
}
|
}
|
||||||
else if (actions.size() > 1 && selectedItem == actions.at(1))
|
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
|
const bool on = !muted && isAudioAvailableAndNotMuted(); // make sure audio is started
|
||||||
ui->led_Audio->setOn(on);
|
ui->led_Audio->setOn(on);
|
||||||
@@ -311,6 +311,6 @@ namespace BlackGui::Components
|
|||||||
{
|
{
|
||||||
if (!sGui || !sGui->getCContextAudioBase() || sGui->isShuttingDown()) { return false; }
|
if (!sGui || !sGui->getCContextAudioBase() || sGui->isShuttingDown()) { return false; }
|
||||||
if (!sGui->getCContextAudioBase()->isAudioStarted()) { return false; }
|
if (!sGui->getCContextAudioBase()->isAudioStarted()) { return false; }
|
||||||
return !sGui->getCContextAudioBase()->isMuted();
|
return !sGui->getCContextAudioBase()->isOutputMuted();
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ namespace BlackGui::Components
|
|||||||
//! Context menu requested
|
//! Context menu requested
|
||||||
void onCustomAudioContextMenuRequested(const QPoint &position);
|
void onCustomAudioContextMenuRequested(const QPoint &position);
|
||||||
|
|
||||||
//! Mute changed
|
//! Output mute changed
|
||||||
void onMuteChanged(bool muted);
|
void onOutputMuteChanged(bool muted);
|
||||||
|
|
||||||
//! Audio started
|
//! Audio started
|
||||||
void onAudioStarted(const BlackMisc::Audio::CAudioDeviceInfo &input, const BlackMisc::Audio::CAudioDeviceInfo &output);
|
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->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMainKeypadAreaComponent::connectionStatusChanged);
|
||||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ownAircraftCockpitChanged);
|
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);
|
connect(this, &CMainKeypadAreaComponent::commandEntered, sGui->getCoreFacade(), &CCoreFacade::parseCommandLine);
|
||||||
|
|
||||||
QPointer<CMainKeypadAreaComponent> myself(this);
|
QPointer<CMainKeypadAreaComponent> myself(this);
|
||||||
@@ -139,8 +139,8 @@ namespace BlackGui::Components
|
|||||||
}
|
}
|
||||||
else if (senderButton == ui->pb_SoundMute && sGui->getIContextAudio())
|
else if (senderButton == ui->pb_SoundMute && sGui->getIContextAudio())
|
||||||
{
|
{
|
||||||
const bool mute = sGui->getCContextAudioBase()->isMuted();
|
const bool mute = sGui->getCContextAudioBase()->isOutputMuted();
|
||||||
sGui->getCContextAudioBase()->setMute(!mute);
|
sGui->getCContextAudioBase()->setOutputMute(!mute);
|
||||||
}
|
}
|
||||||
else if (senderButton == ui->pb_Connect)
|
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
|
// check state to avoid undelibarate signals
|
||||||
if (muted != ui->pb_SoundMute->isChecked())
|
if (muted != ui->pb_SoundMute->isChecked())
|
||||||
@@ -257,7 +257,7 @@ namespace BlackGui::Components
|
|||||||
if (!sGui || sGui->isShuttingDown() || !sGui->supportsContexts()) { return; }
|
if (!sGui || sGui->isShuttingDown() || !sGui->supportsContexts()) { return; }
|
||||||
if (sGui->getCContextAudioBase())
|
if (sGui->getCContextAudioBase())
|
||||||
{
|
{
|
||||||
this->muteChanged(sGui->getCContextAudioBase()->isMuted());
|
this->outputMuteChanged(sGui->getCContextAudioBase()->isOutputMuted());
|
||||||
}
|
}
|
||||||
this->updateConnectionStatus();
|
this->updateConnectionStatus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ namespace BlackGui::Components
|
|||||||
//! \copydoc BlackCore::Context::IContextOwnAircraft::changedAircraftCockpit
|
//! \copydoc BlackCore::Context::IContextOwnAircraft::changedAircraftCockpit
|
||||||
void ownAircraftCockpitChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
void ownAircraftCockpitChanged(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
||||||
|
|
||||||
//! \copydoc BlackCore::Context::IContextAudio::changedMute
|
//! \copydoc BlackCore::Context::IContextAudio::changedOutputMute
|
||||||
void muteChanged(bool muted);
|
void outputMuteChanged(bool muted);
|
||||||
|
|
||||||
//! If button is info area, identify it
|
//! If button is info area, identify it
|
||||||
CMainInfoAreaComponent::InfoArea buttonToMainInfoArea(const QObject *button) const;
|
CMainInfoAreaComponent::InfoArea buttonToMainInfoArea(const QObject *button) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user