mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
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:
committed by
Mat Sutcliffe
parent
24bc57ac32
commit
6fc3d55d9a
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -53,14 +53,14 @@ namespace BlackGui
|
||||
this->adjustTextSize();
|
||||
|
||||
ui->lbl_Audio->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this, &CInfoBarStatusComponent::onCustomAudioContextMenuRequested);
|
||||
connect(ui->lbl_Audio, &QLabel::customContextMenuRequested, this, &CInfoBarStatusComponent::onCustomAudioContextMenuRequested);
|
||||
connect(ui->comp_XpdrMode, &CTransponderModeComponent::changed, this, &CInfoBarStatusComponent::transponderModeChanged);
|
||||
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
||||
if (sGui->getIContextSimulator())
|
||||
{
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CInfoBarStatusComponent::onSimulatorStatusChanged, Qt::QueuedConnection);
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::modelSetChanged, this, &CInfoBarStatusComponent::onMapperReady);
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::modelSetChanged, this, &CInfoBarStatusComponent::onMapperReady);
|
||||
connect(sGui, &CGuiApplication::changedInternetAccessibility, this, &CInfoBarStatusComponent::onInternetAccessibleChanged);
|
||||
|
||||
// initial values
|
||||
@@ -70,7 +70,7 @@ namespace BlackGui
|
||||
|
||||
if (sGui->getIContextNetwork())
|
||||
{
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CInfoBarStatusComponent::onNetworkConnectionChanged);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CInfoBarStatusComponent::onNetworkConnectionChanged, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
if (sGui->getIContextApplication())
|
||||
@@ -81,7 +81,9 @@ namespace BlackGui
|
||||
ui->led_Audio->setOn(CInfoBarStatusComponent::isAudioAvailableAndNotMuted());
|
||||
if (sGui->getCContextAudioBase())
|
||||
{
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedMute, this, &CInfoBarStatusComponent::onMuteChanged);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedMute, this, &CInfoBarStatusComponent::onMuteChanged, Qt::QueuedConnection);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::startedAudio, this, &CInfoBarStatusComponent::onAudioStarted, Qt::QueuedConnection);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::stoppedAudio, this, &CInfoBarStatusComponent::onAudioStopped, Qt::QueuedConnection);
|
||||
|
||||
// PTT as received on audio
|
||||
// that also would need to be reconnected if audio is disabled/enabled
|
||||
@@ -91,7 +93,7 @@ namespace BlackGui
|
||||
QPointer<CInfoBarStatusComponent> myself(this);
|
||||
QTimer::singleShot(5000, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
if (!sGui || sGui->isShuttingDown() || !myself) { return; }
|
||||
this->updateValues();
|
||||
});
|
||||
}
|
||||
@@ -103,14 +105,14 @@ namespace BlackGui
|
||||
{
|
||||
this->updateSpacing();
|
||||
CLedWidget::LedShape shape = CLedWidget::Circle;
|
||||
ui->led_DBus->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "DBus connected", "DBus disconnected", 14);
|
||||
ui->led_Network->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Network connected", "Network disconnected", 14);
|
||||
ui->led_Simulator->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Blue, shape, "Simulator running", "Simulator disconnected", "Simulator connected", 14);
|
||||
ui->led_DBus->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "DBus connected", "DBus disconnected", 14);
|
||||
ui->led_Network->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Network connected", "Network disconnected", 14);
|
||||
ui->led_Simulator->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Blue, shape, "Simulator running", "Simulator disconnected", "Simulator connected", 14);
|
||||
ui->led_MapperReady->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Blue, shape, "Mapper ready", "Mappings not yet loaded", "Mappings not yet loaded", 14);
|
||||
|
||||
shape = CLedWidget::Rounded;
|
||||
ui->led_Ptt->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Ptt", "Silence", 18);
|
||||
ui->led_Audio->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "On", "Muted", 18);
|
||||
ui->led_Ptt->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Ptt", "Silence", 18);
|
||||
ui->led_Audio->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "On", "Muted", 18);
|
||||
this->onInternetAccessibleChanged(sGui->isInternetAccessible());
|
||||
}
|
||||
|
||||
@@ -240,7 +242,20 @@ namespace BlackGui
|
||||
|
||||
void CInfoBarStatusComponent::onMuteChanged(bool muted)
|
||||
{
|
||||
ui->led_Audio->setOn(!muted);
|
||||
const bool on = !muted && isAudioAvailableAndNotMuted(); // make sure audio is started
|
||||
ui->led_Audio->setOn(on);
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::onAudioStarted(const CAudioDeviceInfo &input, const CAudioDeviceInfo &output)
|
||||
{
|
||||
Q_UNUSED(input)
|
||||
Q_UNUSED(output)
|
||||
this->updateValues();
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::onAudioStopped()
|
||||
{
|
||||
this->updateValues();
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::onMapperReady()
|
||||
@@ -276,12 +291,12 @@ namespace BlackGui
|
||||
Q_UNUSED(active)
|
||||
Q_UNUSED(pttcom)
|
||||
|
||||
/**
|
||||
/*
|
||||
if (pttcom == COM1 || pttcom == COM2)
|
||||
{
|
||||
this->onPttChanged(active);
|
||||
}
|
||||
**/
|
||||
*/
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::onInternetAccessibleChanged(bool access)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackgui/blackguiexport.h"
|
||||
|
||||
#include "blackmisc/audio/ptt.h"
|
||||
#include "blackmisc/audio/audiodeviceinfo.h"
|
||||
#include "blackmisc/input/actionhotkeydefs.h"
|
||||
#include "blackmisc/network/connectionstatus.h"
|
||||
|
||||
@@ -88,6 +89,12 @@ namespace BlackGui
|
||||
//! Mute changed
|
||||
void onMuteChanged(bool muted);
|
||||
|
||||
//! Audio started
|
||||
void onAudioStarted(const BlackMisc::Audio::CAudioDeviceInfo &input, const BlackMisc::Audio::CAudioDeviceInfo &output);
|
||||
|
||||
//! Audio stopped
|
||||
void onAudioStopped();
|
||||
|
||||
//! Mapper is ready
|
||||
void onMapperReady();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user