[AFV] Check client started in the correct thread

This commit is contained in:
Roland Rossgotterer
2019-10-12 13:30:00 +02:00
parent 7951b9f15d
commit be4d40ba7d

View File

@@ -182,18 +182,12 @@ namespace BlackCore
QMetaObject::invokeMethod(this, [ = ]() { if (myself) restartWithNewDevices(inputDevice, outputDevice); }); QMetaObject::invokeMethod(this, [ = ]() { if (myself) restartWithNewDevices(inputDevice, outputDevice); });
} }
if (m_isStarted) { this->stopAudio(); } this->stopAudio();
this->startAudio(inputDevice, outputDevice, allTransceiverIds()); this->startAudio(inputDevice, outputDevice, allTransceiverIds());
} }
void CAfvClient::startAudio(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice, const QVector<quint16> &transceiverIDs) 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()) if (QThread::currentThread() != this->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
@@ -201,6 +195,12 @@ namespace BlackCore
return; return;
} }
if (m_isStarted)
{
CLogMessage(this).info(u"Client already started");
return;
}
this->initTransceivers(); this->initTransceivers();
if (m_soundcardSampleProvider) { m_soundcardSampleProvider->deleteLater(); } if (m_soundcardSampleProvider) { m_soundcardSampleProvider->deleteLater(); }
@@ -233,12 +233,6 @@ namespace BlackCore
void CAfvClient::stopAudio() void CAfvClient::stopAudio()
{ {
if (!m_isStarted)
{
CLogMessage(this).info(u"Client NOT started");
return;
}
if (QThread::currentThread() != this->thread()) if (QThread::currentThread() != this->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
@@ -247,6 +241,12 @@ namespace BlackCore
return; return;
} }
if (!m_isStarted)
{
CLogMessage(this).info(u"Client NOT started");
return;
}
m_isStarted = false; m_isStarted = false;
m_connection->setReceiveAudio(false); m_connection->setReceiveAudio(false);