mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refactor: Remove secondary way to start/stop AFV client
To reduce complexity, there should only be a single way to start the AFV client (done on connectionStatusChange of IContextNetwork)
This commit is contained in:
@@ -227,19 +227,6 @@ namespace BlackCore::Context
|
||||
QObject::disconnect(this);
|
||||
}
|
||||
|
||||
void CContextAudioBase::enableVoiceClientAndStart()
|
||||
{
|
||||
this->initVoiceClient();
|
||||
if (m_voiceClient)
|
||||
{
|
||||
m_voiceClient->startAudio();
|
||||
const bool connected = this->connectAudioWithNetworkCredentials();
|
||||
Q_UNUSED(connected)
|
||||
|
||||
// one reason for not connecting is NOT using the VATSIM ecosystem
|
||||
}
|
||||
}
|
||||
|
||||
void CContextAudioBase::setRxTx(bool rx1, bool tx1, bool rx2, bool tx2)
|
||||
{
|
||||
if (m_voiceClient)
|
||||
|
||||
@@ -140,13 +140,6 @@ namespace BlackCore
|
||||
//! Graceful shutdown
|
||||
void gracefulShutdown();
|
||||
|
||||
//! @{
|
||||
//! Enable/disable
|
||||
void enableVoiceClient() { this->initVoiceClient(); }
|
||||
void enableVoiceClientAndStart();
|
||||
void disableVoiceClient() { this->terminateVoiceClient(); }
|
||||
//! @}
|
||||
|
||||
//! @{
|
||||
//! Receive/transmit
|
||||
void setRxTx(bool rx1, bool tx1, bool rx2, bool tx2);
|
||||
|
||||
@@ -19,57 +19,12 @@ namespace BlackGui::Components
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::startedAudio, this, &CAudioAdvancedDistributedComponent::onAudioStarted, Qt::QueuedConnection);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::stoppedAudio, this, &CAudioAdvancedDistributedComponent::onAudioStoppend, Qt::QueuedConnection);
|
||||
connect(ui->pb_EnableDisable, &QPushButton::pressed, this, &CAudioAdvancedDistributedComponent::toggleAudioEnableDisable, Qt::QueuedConnection);
|
||||
connect(ui->pb_StartStop, &QPushButton::pressed, this, &CAudioAdvancedDistributedComponent::toggleAudioStartStop, Qt::QueuedConnection);
|
||||
connect(ui->pb_ReloadRegistered, &QPushButton::pressed, this, &CAudioAdvancedDistributedComponent::reloadRegisteredDevices, Qt::QueuedConnection);
|
||||
|
||||
this->setButtons();
|
||||
}
|
||||
|
||||
CAudioAdvancedDistributedComponent::~CAudioAdvancedDistributedComponent()
|
||||
{}
|
||||
|
||||
void CAudioAdvancedDistributedComponent::toggleAudioStartStop()
|
||||
{
|
||||
if (!hasContexts()) { return; }
|
||||
const bool started = sGui->getCContextAudioBase()->isAudioStarted();
|
||||
if (started)
|
||||
{
|
||||
sGui->getCContextAudioBase()->afvClient()->disconnectFromAndStop();
|
||||
}
|
||||
else
|
||||
{
|
||||
sGui->getCContextAudioBase()->afvClient()->startAudio();
|
||||
if (sGui->getIContextNetwork()->isConnected())
|
||||
{
|
||||
const bool connected = sGui->getCContextAudioBase()->connectAudioWithNetworkCredentials();
|
||||
Q_UNUSED(connected)
|
||||
|
||||
// one reason for not connecting is NOT using the VATSIM ecosystem
|
||||
}
|
||||
}
|
||||
|
||||
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::reloadRegisteredDevices()
|
||||
{
|
||||
if (!hasContexts()) { return; }
|
||||
@@ -77,40 +32,6 @@ namespace BlackGui::Components
|
||||
ui->tvp_RegisteredDevices->updateContainerMaybeAsync(registeredDevices);
|
||||
}
|
||||
|
||||
void CAudioAdvancedDistributedComponent::setButtons()
|
||||
{
|
||||
if (!hasContexts()) { return; }
|
||||
const bool started = sGui->getCContextAudioBase()->isAudioStarted();
|
||||
const bool enabled = sGui->getCContextAudioBase()->isAudioEnabled();
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(inputDevice)
|
||||
Q_UNUSED(outputDevice)
|
||||
this->setButtons();
|
||||
this->reloadRegisteredDevices();
|
||||
}
|
||||
|
||||
void CAudioAdvancedDistributedComponent::onAudioStoppend()
|
||||
{
|
||||
this->setButtons();
|
||||
this->reloadRegisteredDevices();
|
||||
}
|
||||
|
||||
bool CAudioAdvancedDistributedComponent::hasContexts()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getCContextAudioBase()) { return false; }
|
||||
|
||||
@@ -35,21 +35,6 @@ namespace BlackGui::Components
|
||||
private:
|
||||
QScopedPointer<Ui::CAudioAdvancedDistributedComponent> ui;
|
||||
|
||||
//! Audio start/stop
|
||||
void toggleAudioStartStop();
|
||||
|
||||
//! Audio enable/disable
|
||||
void toggleAudioEnableDisable();
|
||||
|
||||
//! @{
|
||||
//! Start/stop button
|
||||
void setButtons();
|
||||
void setButtons(int delayMs);
|
||||
//! @}
|
||||
|
||||
void onAudioStarted(const BlackMisc::Audio::CAudioDeviceInfo &inputDevice, const BlackMisc::Audio::CAudioDeviceInfo &outputDevice);
|
||||
void onAudioStoppend();
|
||||
|
||||
//! Contexts
|
||||
static bool hasContexts();
|
||||
};
|
||||
|
||||
@@ -14,13 +14,6 @@
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pb_EnableDisable">
|
||||
<property name="text">
|
||||
<string>enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="BlackGui::Views::CAudioDeviceInfoView" name="tvp_RegisteredDevices">
|
||||
<property name="selectionMode">
|
||||
@@ -37,20 +30,6 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pb_StartStop">
|
||||
<property name="text">
|
||||
<string>stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_EnableDisable">
|
||||
<property name="text">
|
||||
<string>Audio:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="pb_ReloadRegistered">
|
||||
<property name="text">
|
||||
@@ -68,8 +47,6 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>pb_StartStop</tabstop>
|
||||
<tabstop>pb_EnableDisable</tabstop>
|
||||
<tabstop>tvp_RegisteredDevices</tabstop>
|
||||
<tabstop>pb_ReloadRegistered</tabstop>
|
||||
</tabstops>
|
||||
|
||||
@@ -195,7 +195,7 @@
|
||||
<set>Qt::BottomDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Adv./distributed audio</string>
|
||||
<string>Distributed audio</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
|
||||
Reference in New Issue
Block a user