mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
Ref T730, Ref T739, make sure transmitting receivers are correct
* deferred init, make sure values from context are used (if possible) * only use 1 transmitting transceiver
This commit is contained in:
committed by
Mat Sutcliffe
parent
160589c975
commit
f81a9e8447
@@ -55,13 +55,8 @@ namespace BlackCore
|
|||||||
connect(m_connection, &CClientConnection::audioReceived, this, &CAfvClient::audioOutDataAvailable);
|
connect(m_connection, &CClientConnection::audioReceived, this, &CAfvClient::audioOutDataAvailable);
|
||||||
connect(m_voiceServerPositionTimer, &QTimer::timeout, this, &CAfvClient::onPositionUpdateTimer);
|
connect(m_voiceServerPositionTimer, &QTimer::timeout, this, &CAfvClient::onPositionUpdateTimer);
|
||||||
|
|
||||||
// transceivers
|
// deferred init
|
||||||
this->initTransceivers();
|
QTimer::singleShot(1000, this, &CAfvClient::deferredInit);
|
||||||
|
|
||||||
// init by settings
|
|
||||||
this->onSettingsChanged();
|
|
||||||
|
|
||||||
CLogMessage(this).info(u"UserClient instantiated");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CAfvClient::getCallsign() const
|
QString CAfvClient::getCallsign() const
|
||||||
@@ -91,15 +86,22 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// init with context values
|
// init with context values
|
||||||
this->initWithContext();
|
this->connectWithContexts();
|
||||||
|
if (m_connectedWithContext && hasContext())
|
||||||
|
{
|
||||||
|
// update from context
|
||||||
|
this->updateTransceivers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::initWithContext()
|
void CAfvClient::connectWithContexts()
|
||||||
{
|
{
|
||||||
|
if (m_connectedWithContext) { return; }
|
||||||
if (!hasContext()) { return; }
|
if (!hasContext()) { return; }
|
||||||
this->disconnect(sApp->getIContextOwnAircraft());
|
this->disconnect(sApp->getIContextOwnAircraft());
|
||||||
sApp->getIContextOwnAircraft()->disconnect(this);
|
sApp->getIContextOwnAircraft()->disconnect(this);
|
||||||
connect(sApp->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CAfvClient::updateTransceiversFromContext, Qt::QueuedConnection);
|
connect(sApp->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CAfvClient::onUpdateTransceiversFromContext, Qt::QueuedConnection);
|
||||||
|
m_connectedWithContext = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::connectTo(const QString &cid, const QString &password, const QString &callsign)
|
void CAfvClient::connectTo(const QString &cid, const QString &password, const QString &callsign)
|
||||||
@@ -113,7 +115,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// called in CAfvClient thread
|
// called in CAfvClient thread
|
||||||
this->initWithContext();
|
this->connectWithContexts();
|
||||||
this->setCallsign(callsign);
|
this->setCallsign(callsign);
|
||||||
|
|
||||||
m_connection->connectTo(cid, password, callsign);
|
m_connection->connectTo(cid, password, callsign);
|
||||||
@@ -390,12 +392,10 @@ namespace BlackCore
|
|||||||
newEnabledTransceivers.push_back(transceiver);
|
newEnabledTransceivers.push_back(transceiver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_connection->updateTransceivers(callsign, newEnabledTransceivers);
|
|
||||||
|
|
||||||
if (m_soundcardSampleProvider)
|
// in connection and soundcard only use the enabled tarnsceivers
|
||||||
{
|
if (m_connection) { m_connection->updateTransceivers(callsign, newEnabledTransceivers); }
|
||||||
m_soundcardSampleProvider->updateRadioTransceivers(m_transceivers);
|
if (m_soundcardSampleProvider) { m_soundcardSampleProvider->updateRadioTransceivers(newEnabledTransceivers); }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::setTransmittingTransceiver(quint16 transceiverID)
|
void CAfvClient::setTransmittingTransceiver(quint16 transceiverID)
|
||||||
@@ -676,7 +676,7 @@ namespace BlackCore
|
|||||||
this->setBypassEffects(!audioSettings.isAudioEffectsEnabled());
|
this->setBypassEffects(!audioSettings.isAudioEffectsEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAfvClient::updateTransceiversFromContext(const CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
void CAfvClient::onUpdateTransceiversFromContext(const CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||||
{
|
{
|
||||||
Q_UNUSED(originator)
|
Q_UNUSED(originator)
|
||||||
this->updatePosition(aircraft.latitude().value(CAngleUnit::deg()),
|
this->updatePosition(aircraft.latitude().value(CAngleUnit::deg()),
|
||||||
@@ -695,8 +695,16 @@ namespace BlackCore
|
|||||||
|
|
||||||
this->enableComUnit(CComSystem::Com1, tx1 || rx1);
|
this->enableComUnit(CComSystem::Com1, tx1 || rx1);
|
||||||
this->enableComUnit(CComSystem::Com2, tx2 || rx2);
|
this->enableComUnit(CComSystem::Com2, tx2 || rx2);
|
||||||
this->setTransmittingComUnit(CComSystem::Com1);
|
|
||||||
this->setTransmittingComUnit(CComSystem::Com2);
|
// currently only transmitting at one unit
|
||||||
|
if (tx1)
|
||||||
|
{
|
||||||
|
this->setTransmittingComUnit(CComSystem::Com1);
|
||||||
|
}
|
||||||
|
else if (tx2)
|
||||||
|
{
|
||||||
|
this->setTransmittingComUnit(CComSystem::Com2);
|
||||||
|
}
|
||||||
|
|
||||||
this->updateTransceivers();
|
this->updateTransceivers();
|
||||||
emit this->updatedFromOwnAircraftCockpit();
|
emit this->updatedFromOwnAircraftCockpit();
|
||||||
@@ -721,6 +729,18 @@ namespace BlackCore
|
|||||||
return CComSystem::Com1;
|
return CComSystem::Com1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAfvClient::deferredInit()
|
||||||
|
{
|
||||||
|
// transceivers
|
||||||
|
this->initTransceivers();
|
||||||
|
|
||||||
|
// init by settings
|
||||||
|
this->onSettingsChanged();
|
||||||
|
|
||||||
|
// info
|
||||||
|
CLogMessage(this).info(u"UserClient instantiated (deferred init)");
|
||||||
|
}
|
||||||
|
|
||||||
bool CAfvClient::hasContext()
|
bool CAfvClient::hasContext()
|
||||||
{
|
{
|
||||||
return sApp && !sApp->isShuttingDown() && sApp->getIContextOwnAircraft();
|
return sApp && !sApp->isShuttingDown() && sApp->getIContextOwnAircraft();
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ namespace BlackCore
|
|||||||
void onSettingsChanged();
|
void onSettingsChanged();
|
||||||
|
|
||||||
void updateTransceivers(bool updateFrequencies = true);
|
void updateTransceivers(bool updateFrequencies = true);
|
||||||
void updateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
void onUpdateTransceiversFromContext(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
||||||
|
|
||||||
static constexpr int PositionUpdatesMs = 5000; //!< position timer
|
static constexpr int PositionUpdatesMs = 5000; //!< position timer
|
||||||
static constexpr int SampleRate = 48000;
|
static constexpr int SampleRate = 48000;
|
||||||
@@ -282,10 +282,13 @@ namespace BlackCore
|
|||||||
Audio::InputVolumeStreamArgs m_inputVolumeStream;
|
Audio::InputVolumeStreamArgs m_inputVolumeStream;
|
||||||
Audio::OutputVolumeStreamArgs m_outputVolumeStream;
|
Audio::OutputVolumeStreamArgs m_outputVolumeStream;
|
||||||
|
|
||||||
|
void deferredInit();
|
||||||
void initTransceivers();
|
void initTransceivers();
|
||||||
void initWithContext();
|
void connectWithContexts();
|
||||||
static bool hasContext();
|
static bool hasContext();
|
||||||
|
|
||||||
|
std::atomic_bool m_connectedWithContext { false };
|
||||||
|
|
||||||
mutable QMutex m_mutex;
|
mutable QMutex m_mutex;
|
||||||
mutable QMutex m_mutexInputStream;
|
mutable QMutex m_mutexInputStream;
|
||||||
mutable QMutex m_mutexOutputStream;
|
mutable QMutex m_mutexOutputStream;
|
||||||
|
|||||||
Reference in New Issue
Block a user