[AFV] Ref T739, audio can now be disabled from UI

This commit is contained in:
Klaus Basan
2019-10-26 02:54:11 +02:00
committed by Mat Sutcliffe
parent c8097cc899
commit 9447db00bc
10 changed files with 197 additions and 66 deletions

View File

@@ -186,13 +186,13 @@ namespace BlackCore
} }
} }
void CAfvClient::disconnectFrom() void CAfvClient::disconnectFrom(bool stop)
{ {
if (QThread::currentThread() != thread()) if (QThread::currentThread() != thread())
{ {
// Method needs to be executed in the object thread since it will create new QObject children // Method needs to be executed in the object thread since it will create new QObject children
QPointer<CAfvClient> myself(this); QPointer<CAfvClient> myself(this);
QMetaObject::invokeMethod(this, [ = ]() { if (myself) disconnectFrom(); }); QMetaObject::invokeMethod(this, [ = ]() { if (myself) disconnectFrom(stop); });
return; return;
} }
@@ -203,6 +203,8 @@ namespace BlackCore
m_connection->disconnectFrom(); m_connection->disconnectFrom();
} }
emit connectionStatusChanged(Disconnected); emit connectionStatusChanged(Disconnected);
if (stop) { this->stopAudio(); }
} }
QStringList CAfvClient::availableInputDevices() const QStringList CAfvClient::availableInputDevices() const

View File

@@ -94,7 +94,11 @@ namespace BlackCore
//! Disconnect from network //! Disconnect from network
//! \threadsafe //! \threadsafe
//! \remark runs in thread of CAfvClient object and is ASYNC when called from another thread //! \remark runs in thread of CAfvClient object and is ASYNC when called from another thread
Q_INVOKABLE void disconnectFrom(); //! @{
void disconnectFrom(bool stop);
Q_INVOKABLE void disconnectFrom() { this->disconnectFrom(false); }
void disconnectFromAndStop() { this->disconnectFrom(true); }
//! @}
//! Audio devices @{ //! Audio devices @{
Q_INVOKABLE QStringList availableInputDevices() const; Q_INVOKABLE QStringList availableInputDevices() const;

View File

@@ -69,7 +69,7 @@ namespace BlackCore
this->connectToVoiceServer(); this->connectToVoiceServer();
// taskServerConnectionCheck.Start(); // taskServerConnectionCheck.Start();
CLogMessage(this).debug(u"Connected: '%1'") << callsign; CLogMessage(this).info(u"Connected: '%1' to voice server, socket open: ") << callsign << boolToYesNo(m_udpSocket->isOpen());
} }
// callback of the calling parent // callback of the calling parent
@@ -121,11 +121,11 @@ namespace BlackCore
void CClientConnection::connectToVoiceServer() void CClientConnection::connectToVoiceServer()
{ {
QHostAddress localAddress(QHostAddress::AnyIPv4); const QHostAddress localAddress(QHostAddress::AnyIPv4);
m_udpSocket->bind(localAddress); m_udpSocket->bind(localAddress);
m_voiceServerTimer->start(3000); m_voiceServerTimer->start(3000);
CLogMessage(this).info(u"Connected to voice server '%1'") << m_connection.getTokens().VoiceServer.addressIpV4; CLogMessage(this).info(u"Connected to voice server '%2'") << m_connection.getTokens().VoiceServer.addressIpV4;
} }
void CClientConnection::disconnectFromVoiceServer() void CClientConnection::disconnectFromVoiceServer()

View File

@@ -111,6 +111,32 @@ namespace BlackCore
CIdentifiable(this), CIdentifiable(this),
m_voiceClient(new CAfvClient(CVoiceSetup().getAfvVoiceServerUrl(), this)) m_voiceClient(new CAfvClient(CVoiceSetup().getAfvVoiceServerUrl(), this))
{ {
this->initVoiceClient();
const CSettings as = m_audioSettings.getThreadLocal();
this->setVoiceOutputVolume(as.getOutVolume());
m_selcalPlayer = new CSelcalPlayer(CAudioDeviceInfo::getDefaultOutputDevice(), this);
this->changeDeviceSettings();
QPointer<CContextAudioBase> myself(this);
QTimer::singleShot(5000, this, [ = ]
{
if (!myself || !sApp || sApp->isShuttingDown()) { return; }
myself->onChangedAudioSettings();
});
}
CContextAudioBase::~CContextAudioBase()
{
this->gracefulShutdown();
}
void CContextAudioBase::initVoiceClient()
{
if (!m_voiceClient)
{
m_voiceClient = new CAfvClient(CVoiceSetup().getAfvVoiceServerUrl(), this);
}
const CVoiceSetup vs = m_voiceSettings.getThreadLocal(); const CVoiceSetup vs = m_voiceSettings.getThreadLocal();
m_voiceClient->updateVoiceServerUrl(vs.getAfvVoiceServerUrl()); m_voiceClient->updateVoiceServerUrl(vs.getAfvVoiceServerUrl());
@@ -144,33 +170,16 @@ namespace BlackCore
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);
const CSettings as = m_audioSettings.getThreadLocal();
this->setVoiceOutputVolume(as.getOutVolume());
m_selcalPlayer = new CSelcalPlayer(CAudioDeviceInfo::getDefaultOutputDevice(), this);
this->changeDeviceSettings();
QPointer<CContextAudioBase> myself(this);
QTimer::singleShot(5000, this, [ = ]
{
if (!myself || !sApp || sApp->isShuttingDown()) { return; }
myself->onChangedAudioSettings();
});
} }
CContextAudioBase::~CContextAudioBase() void CContextAudioBase::terminateVoiceClient()
{
gracefulShutdown();
}
void CContextAudioBase::gracefulShutdown()
{ {
if (m_voiceClient) if (m_voiceClient)
{ {
m_voiceClient->gracefulShutdown(); m_voiceClient->gracefulShutdown();
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_voiceClient), Q_FUNC_INFO, "Needs to be back in current thread"); Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_voiceClient), Q_FUNC_INFO, "Needs to be back in current thread");
m_voiceClient->deleteLater();
m_voiceClient = nullptr; m_voiceClient = nullptr;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if (m_winCoInitialized) if (m_winCoInitialized)
{ {
@@ -179,9 +188,23 @@ namespace BlackCore
} }
#endif #endif
} }
}
void CContextAudioBase::gracefulShutdown()
{
this->terminateVoiceClient();
QObject::disconnect(this); QObject::disconnect(this);
} }
void CContextAudioBase::enableVoiceClientAndStart()
{
this->initVoiceClient();
if (m_voiceClient) {
m_voiceClient->startAudio();
this->connectAudioWithNetworkCredentials();
}
}
const CIdentifier &CContextAudioBase::audioRunsWhere() const const CIdentifier &CContextAudioBase::audioRunsWhere() const
{ {
static const CIdentifier i("CContextAudioBaseImpl"); static const CIdentifier i("CContextAudioBaseImpl");
@@ -200,6 +223,28 @@ namespace BlackCore
return m_voiceClient->isTransmittingdComUnit(comUnit); return m_voiceClient->isTransmittingdComUnit(comUnit);
} }
bool CContextAudioBase::connectAudioWithNetworkCredentials()
{
if (!m_voiceClient) { return false; }
if (!sApp || sApp->isShuttingDown() || !sApp->getIContextNetwork()) { return false; }
const CEcosystem ecoSystem = this->getIContextNetwork()->getConnectedServer().getEcosystem();
if (ecoSystem != CEcosystem::vatsim())
{
CLogMessage(this).info(u"Will not use AFV as ecosystem is '%1'") << ecoSystem.toQString(true);
return false;
}
const CVoiceSetup vs = m_voiceSettings.getThreadLocal();
m_voiceClient->updateVoiceServerUrl(vs.getAfvVoiceServerUrl());
const CUser connectedUser = this->getIContextNetwork()->getConnectedServer().getUser();
const QString client = "swift " % BlackConfig::CBuildConfig::getShortVersionString();
m_voiceClient->connectTo(connectedUser.getId(), connectedUser.getPassword(), connectedUser.getCallsign().asString(), client);
return true;
}
bool CContextAudioBase::isAudioConnected() const bool CContextAudioBase::isAudioConnected() const
{ {
return m_voiceClient && m_voiceClient->isConnected(); return m_voiceClient && m_voiceClient->isConnected();
@@ -212,7 +257,7 @@ namespace BlackCore
QString CContextAudioBase::audioRunsWhereInfo() const QString CContextAudioBase::audioRunsWhereInfo() const
{ {
static const QString s = QStringLiteral("Audio on '%1', '%2'.").arg(audioRunsWhere().getMachineName(), audioRunsWhere().getProcessName()); const QString s = QStringLiteral("[%1] Audio on '%2', '%3'.").arg(boolToEnabledDisabled(this->isAudioStarted()), audioRunsWhere().getMachineName(), audioRunsWhere().getProcessName());
return s; return s;
} }
@@ -439,19 +484,7 @@ namespace BlackCore
// we only change network connection of AFC client here // we only change network connection of AFC client here
if (to.isConnected() && this->getIContextNetwork()) if (to.isConnected() && this->getIContextNetwork())
{ {
const CEcosystem ecoSystem = this->getIContextNetwork()->getConnectedServer().getEcosystem(); this->connectAudioWithNetworkCredentials();
if (ecoSystem != CEcosystem::vatsim())
{
CLogMessage(this).info(u"Will not use AFV as ecosystem is '%1'") << ecoSystem.toQString(true);
return;
}
const CVoiceSetup vs = m_voiceSettings.getThreadLocal();
m_voiceClient->updateVoiceServerUrl(vs.getAfvVoiceServerUrl());
const CUser connectedUser = this->getIContextNetwork()->getConnectedServer().getUser();
const QString client = "swift " % BlackConfig::CBuildConfig::getShortVersionString();
m_voiceClient->connectTo(connectedUser.getId(), connectedUser.getPassword(), connectedUser.getCallsign().asString(), client);
} }
else if (to.isDisconnected()) else if (to.isDisconnected())
{ {

View File

@@ -41,7 +41,6 @@
// clazy:excludeall=const-signal-or-slot // clazy:excludeall=const-signal-or-slot
//! \addtogroup dbus //! \addtogroup dbus
//! @{ //! @{
@@ -123,6 +122,12 @@ namespace BlackCore
//! Graceful shutdown //! Graceful shutdown
void gracefulShutdown(); void gracefulShutdown();
//! Enable/disable @{
void enableVoiceClient() { this->initVoiceClient(); }
void enableVoiceClientAndStart();
void disableVoiceClient() { this->terminateVoiceClient(); }
//! @}
// -------- parts which can run in core and GUI, referring to local voice client ------------ // -------- parts which can run in core and GUI, referring to local voice client ------------
//! Audio devices //! Audio devices
@@ -177,12 +182,19 @@ namespace BlackCore
//! Is COM unit transmitting? //! Is COM unit transmitting?
bool isTransmittingComUnit(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const; bool isTransmittingComUnit(BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
//! Connect to audio with network credentials
//! \remark if there is no network connection/credential this just returns
bool connectAudioWithNetworkCredentials();
//! Is audio connected? //! Is audio connected?
bool isAudioConnected() const; bool isAudioConnected() const;
//! Is audio started? //! Is audio started?
bool isAudioStarted() const; bool isAudioStarted() const;
//! Is audio enabled?
bool isAudioEnabled() const { return m_voiceClient; }
//! \todo WORKAROUND to hide the "local signals" //! \todo WORKAROUND to hide the "local signals"
Afv::Clients::CAfvClient *afvClient() const { return m_voiceClient; } Afv::Clients::CAfvClient *afvClient() const { return m_voiceClient; }
@@ -237,11 +249,17 @@ namespace BlackCore
//! Client updated from own aicraft data //! Client updated from own aicraft data
void updatedFromOwnAircraftCockpit(); void updatedFromOwnAircraftCockpit();
**/ Workaround **/
// ------------ local signals ------- // ------------ local signals -------
private: private:
//! Init the voice client
void initVoiceClient();
//! Terminate the voice client
void terminateVoiceClient();
//! Enable/disable voice transmission, nornally used with hotkey //! Enable/disable voice transmission, nornally used with hotkey
//! @{ //! @{
void setVoiceTransmission(bool enable, BlackMisc::Audio::PTTCOM com); void setVoiceTransmission(bool enable, BlackMisc::Audio::PTTCOM com);

View File

@@ -11,6 +11,7 @@
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackcore/context/contextaudio.h" #include "blackcore/context/contextaudio.h"
#include "blackcore/context/contextnetwork.h"
#include "blackcore/afv/clients/afvclient.h" #include "blackcore/afv/clients/afvclient.h"
using namespace BlackMisc::Audio; using namespace BlackMisc::Audio;
@@ -28,9 +29,10 @@ namespace BlackGui
connect(sGui->getCContextAudioBase(), &CContextAudioBase::startedAudio, this, &CAudioAdvancedDistributedComponent::onAudioStarted, Qt::QueuedConnection); connect(sGui->getCContextAudioBase(), &CContextAudioBase::startedAudio, this, &CAudioAdvancedDistributedComponent::onAudioStarted, Qt::QueuedConnection);
connect(sGui->getCContextAudioBase(), &CContextAudioBase::stoppedAudio, this, &CAudioAdvancedDistributedComponent::onAudioStoppend, Qt::QueuedConnection); connect(sGui->getCContextAudioBase(), &CContextAudioBase::stoppedAudio, this, &CAudioAdvancedDistributedComponent::onAudioStoppend, Qt::QueuedConnection);
connect(ui->pb_StartStop, &QPushButton::released, this, &CAudioAdvancedDistributedComponent::toggleAudioStartStop, Qt::QueuedConnection); connect(ui->pb_EnableDisable, &QPushButton::pressed, this, &CAudioAdvancedDistributedComponent::toggleAudioEnableDisable, Qt::QueuedConnection);
connect(ui->pb_StartStop, &QPushButton::pressed, this, &CAudioAdvancedDistributedComponent::toggleAudioStartStop, Qt::QueuedConnection);
this->setStartButton(); this->setButtons();
} }
CAudioAdvancedDistributedComponent::~CAudioAdvancedDistributedComponent() CAudioAdvancedDistributedComponent::~CAudioAdvancedDistributedComponent()
@@ -42,37 +44,73 @@ namespace BlackGui
const bool started = sGui->getCContextAudioBase()->isAudioStarted(); const bool started = sGui->getCContextAudioBase()->isAudioStarted();
if (started) if (started)
{ {
sGui->getCContextAudioBase()->afvClient()->stopAudio(); sGui->getCContextAudioBase()->afvClient()->disconnectFromAndStop();
} }
else else
{ {
sGui->getCContextAudioBase()->afvClient()->startAudio(); sGui->getCContextAudioBase()->afvClient()->startAudio();
if (sGui->getIContextNetwork()->isConnected())
{
sGui->getCContextAudioBase()->connectAudioWithNetworkCredentials();
} }
} }
void CAudioAdvancedDistributedComponent::setStartButton() this->setButtons(2000);
}
void CAudioAdvancedDistributedComponent::toggleAudioEnableDisable()
{
if (!hasContexts()) { return; }
const bool enabled = sGui->getCContextAudioBase()->isAudioEnabled();
if (enabled)
{
sGui->getCContextAudioBase()->disableVoiceClient();
}
else
{
sGui->getCContextAudioBase()->enableVoiceClientAndStart();
}
this->setButtons(2000);
}
void CAudioAdvancedDistributedComponent::setButtons()
{ {
if (!hasContexts()) { return; } if (!hasContexts()) { return; }
const bool started = sGui->getCContextAudioBase()->isAudioStarted(); const bool started = sGui->getCContextAudioBase()->isAudioStarted();
const bool enabled = sGui->getCContextAudioBase()->isAudioEnabled();
ui->pb_StartStop->setText(started ? "stop" : "start"); ui->pb_StartStop->setText(started ? "stop" : "start");
ui->pb_StartStop->setEnabled(enabled);
ui->pb_EnableDisable->setText(enabled ? "disable" : "enable");
}
void CAudioAdvancedDistributedComponent::setButtons(int delayMs)
{
if (!hasContexts()) { return; }
QPointer<CAudioAdvancedDistributedComponent> myself(this);
QTimer::singleShot(delayMs, this, [ = ]
{
if (!sGui || !myself || sGui->isShuttingDown()) { return; }
this->setButtons();
});
} }
void CAudioAdvancedDistributedComponent::onAudioStarted(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice) void CAudioAdvancedDistributedComponent::onAudioStarted(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice)
{ {
Q_UNUSED(inputDevice) Q_UNUSED(inputDevice)
Q_UNUSED(outputDevice) Q_UNUSED(outputDevice)
this->setStartButton(); this->setButtons();
} }
void CAudioAdvancedDistributedComponent::onAudioStoppend() void CAudioAdvancedDistributedComponent::onAudioStoppend()
{ {
this->setStartButton(); this->setButtons();
} }
bool CAudioAdvancedDistributedComponent::hasContexts() bool CAudioAdvancedDistributedComponent::hasContexts()
{ {
if (!sGui || sGui->isShuttingDown() || !sGui->getCContextAudioBase()) { return false; } if (!sGui || sGui->isShuttingDown() || !sGui->getCContextAudioBase()) { return false; }
if (!sGui->getCContextAudioBase()->afvClient()) { return false; } if (!sGui->getIContextNetwork()) { return false; }
return true; return true;
} }
} }

View File

@@ -39,8 +39,13 @@ namespace BlackGui
//! Audio start/stop //! Audio start/stop
void toggleAudioStartStop(); void toggleAudioStartStop();
//! Start/stop button //! Audio enable/disable
void setStartButton(); void toggleAudioEnableDisable();
//! Start/stop button @{
void setButtons();
void setButtons(int delayMs);
//! @}
void onAudioStarted(const BlackMisc::Audio::CAudioDeviceInfo &inputDevice, const BlackMisc::Audio::CAudioDeviceInfo &outputDevice); void onAudioStarted(const BlackMisc::Audio::CAudioDeviceInfo &inputDevice, const BlackMisc::Audio::CAudioDeviceInfo &outputDevice);
void onAudioStoppend(); void onAudioStoppend();

View File

@@ -7,29 +7,46 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>166</width> <width>166</width>
<height>32</height> <height>55</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Frame</string> <string>Frame</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="1">
<widget class="QLabel" name="lbl_StartStop"> <widget class="QPushButton" name="pb_EnableDisable">
<property name="text"> <property name="text">
<string>Start/stop audio:</string> <string>enable</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="1" column="1">
<widget class="QPushButton" name="pb_StartStop"> <widget class="QPushButton" name="pb_StartStop">
<property name="text"> <property name="text">
<string>stop</string> <string>stop</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_EnableDisable">
<property name="text">
<string>Enable/disable:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_StartStop">
<property name="text">
<string>Start/stop audio:</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<tabstops>
<tabstop>pb_StartStop</tabstop>
</tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@@ -101,10 +101,7 @@ namespace BlackGui
if (audio) if (audio)
{ {
const QString ai = sGui->getCContextAudioBase()->audioRunsWhereInfo(); this->setAudioRunsWhere();
ui->le_Info->setText(ai);
ui->le_Info->setPlaceholderText(ai);
this->initAudioDeviceLists(); this->initAudioDeviceLists();
// default // default
@@ -121,18 +118,16 @@ namespace BlackGui
Q_ASSERT(c); Q_ASSERT(c);
c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::startedAudio, this, &CAudioDeviceVolumeSetupComponent::onAudioStarted, Qt::QueuedConnection); c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::startedAudio, this, &CAudioDeviceVolumeSetupComponent::onAudioStarted, Qt::QueuedConnection);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::stoppedAudio, this, &CAudioDeviceVolumeSetupComponent::onAudioStopped, Qt::QueuedConnection);
Q_ASSERT(c);
//! \todo Workaround to avoid context signals //! \todo Workaround to avoid context signals
c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::outputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onOutputVU, Qt::QueuedConnection); c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::outputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onOutputVU, Qt::QueuedConnection);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::inputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onInputVU, Qt::QueuedConnection); c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::inputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onInputVU, Qt::QueuedConnection);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::receivedCallsignsChanged, this, &CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged, Qt::QueuedConnection); c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::receivedCallsignsChanged, this, &CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged, Qt::QueuedConnection);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::updatedFromOwnAircraftCockpit, this, &CAudioDeviceVolumeSetupComponent::onUpdatedClientWithCockpitData, Qt::QueuedConnection); c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::updatedFromOwnAircraftCockpit, this, &CAudioDeviceVolumeSetupComponent::onUpdatedClientWithCockpitData, Qt::QueuedConnection);
Q_ASSERT(c); Q_ASSERT(c);
@@ -303,6 +298,12 @@ namespace BlackGui
ui->hs_VolumeOut->setValue((ui->hs_VolumeOut->maximum() - ui->hs_VolumeOut->minimum()) / 2); ui->hs_VolumeOut->setValue((ui->hs_VolumeOut->maximum() - ui->hs_VolumeOut->minimum()) / 2);
} }
void CAudioDeviceVolumeSetupComponent::setAudioRunsWhere()
{
const QString ai = sGui->getCContextAudioBase()->audioRunsWhereInfo();
ui->le_Info->setPlaceholderText(ai);
}
void CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged(const CCallsignSet &com1Callsigns, const CCallsignSet &com2Callsigns) void CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged(const CCallsignSet &com1Callsigns, const CCallsignSet &com2Callsigns)
{ {
const QString info = (com1Callsigns.isEmpty() ? QString() : QStringLiteral("COM1: ") % com1Callsigns.getCallsignsAsString()) % const QString info = (com1Callsigns.isEmpty() ? QString() : QStringLiteral("COM1: ") % com1Callsigns.getCallsignsAsString()) %
@@ -347,6 +348,12 @@ namespace BlackGui
{ {
ui->cb_SetupAudioInputDevice->setCurrentText(input.toQString(true)); ui->cb_SetupAudioInputDevice->setCurrentText(input.toQString(true));
ui->cb_SetupAudioOutputDevice->setCurrentText(output.toQString(true)); ui->cb_SetupAudioOutputDevice->setCurrentText(output.toQString(true));
this->setAudioRunsWhere();
}
void CAudioDeviceVolumeSetupComponent::onAudioStopped()
{
this->setAudioRunsWhere();
} }
bool CAudioDeviceVolumeSetupComponent::onAudioDevicesChanged(const CAudioDeviceInfoList &devices) bool CAudioDeviceVolumeSetupComponent::onAudioDevicesChanged(const CAudioDeviceInfoList &devices)
@@ -354,6 +361,7 @@ namespace BlackGui
if (m_cbDevices.hasSameDevices(devices)) { return false; } // avoid numerous follow up actions if (m_cbDevices.hasSameDevices(devices)) { return false; } // avoid numerous follow up actions
m_cbDevices = devices; m_cbDevices = devices;
this->setAudioRunsWhere();
ui->cb_SetupAudioOutputDevice->clear(); ui->cb_SetupAudioOutputDevice->clear();
ui->cb_SetupAudioInputDevice->clear(); ui->cb_SetupAudioInputDevice->clear();
@@ -374,6 +382,7 @@ namespace BlackGui
if (!i.isEmpty()) { ui->cb_SetupAudioInputDevice->setCurrentText(i); } if (!i.isEmpty()) { ui->cb_SetupAudioInputDevice->setCurrentText(i); }
if (!o.isEmpty()) { ui->cb_SetupAudioOutputDevice->setCurrentText(o); } if (!o.isEmpty()) { ui->cb_SetupAudioOutputDevice->setCurrentText(o); }
return true; return true;
} }

View File

@@ -73,6 +73,9 @@ namespace BlackGui
//! Current audio devices changed //! Current audio devices changed
void onAudioStarted(const BlackMisc::Audio::CAudioDeviceInfo &input, const BlackMisc::Audio::CAudioDeviceInfo &output); void onAudioStarted(const BlackMisc::Audio::CAudioDeviceInfo &input, const BlackMisc::Audio::CAudioDeviceInfo &output);
//! Audio has been stopped
void onAudioStopped();
//! Audio devices changed //! Audio devices changed
bool onAudioDevicesChanged(const BlackMisc::Audio::CAudioDeviceInfoList &devices); bool onAudioDevicesChanged(const BlackMisc::Audio::CAudioDeviceInfoList &devices);
@@ -101,6 +104,8 @@ namespace BlackGui
void onResetVolumeIn(); void onResetVolumeIn();
void onResetVolumeOut(); void onResetVolumeOut();
void setAudioRunsWhere();
// TODO: Move TransceiverReceivingCallsignsChangedArgs to Blackmisc // TODO: Move TransceiverReceivingCallsignsChangedArgs to Blackmisc
void onReceivingCallsignsChanged(const BlackMisc::Aviation::CCallsignSet &com1Callsigns, const BlackMisc::Aviation::CCallsignSet &com2Callsigns); void onReceivingCallsignsChanged(const BlackMisc::Aviation::CCallsignSet &com1Callsigns, const BlackMisc::Aviation::CCallsignSet &com2Callsigns);
void onUpdatedClientWithCockpitData(); void onUpdatedClientWithCockpitData();