mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
[AFV] Check client started in the correct thread
This commit is contained in:
@@ -182,18 +182,12 @@ namespace BlackCore
|
||||
QMetaObject::invokeMethod(this, [ = ]() { if (myself) restartWithNewDevices(inputDevice, outputDevice); });
|
||||
}
|
||||
|
||||
if (m_isStarted) { this->stopAudio(); }
|
||||
this->stopAudio();
|
||||
this->startAudio(inputDevice, outputDevice, allTransceiverIds());
|
||||
}
|
||||
|
||||
void CAfvClient::startAudio(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice, const QVector<quint16> &transceiverIDs)
|
||||
{
|
||||
if (m_isStarted)
|
||||
{
|
||||
CLogMessage(this).info(u"Client already started");
|
||||
return;
|
||||
}
|
||||
|
||||
if (QThread::currentThread() != this->thread())
|
||||
{
|
||||
// Method needs to be executed in the object thread since it will create new QObject children
|
||||
@@ -201,6 +195,12 @@ namespace BlackCore
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isStarted)
|
||||
{
|
||||
CLogMessage(this).info(u"Client already started");
|
||||
return;
|
||||
}
|
||||
|
||||
this->initTransceivers();
|
||||
|
||||
if (m_soundcardSampleProvider) { m_soundcardSampleProvider->deleteLater(); }
|
||||
@@ -233,12 +233,6 @@ namespace BlackCore
|
||||
|
||||
void CAfvClient::stopAudio()
|
||||
{
|
||||
if (!m_isStarted)
|
||||
{
|
||||
CLogMessage(this).info(u"Client NOT started");
|
||||
return;
|
||||
}
|
||||
|
||||
if (QThread::currentThread() != this->thread())
|
||||
{
|
||||
// Method needs to be executed in the object thread since it will create new QObject children
|
||||
@@ -247,6 +241,12 @@ namespace BlackCore
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_isStarted)
|
||||
{
|
||||
CLogMessage(this).info(u"Client NOT started");
|
||||
return;
|
||||
}
|
||||
|
||||
m_isStarted = false;
|
||||
m_connection->setReceiveAudio(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user