diff --git a/src/blackcore/afv/clients/afvclient.cpp b/src/blackcore/afv/clients/afvclient.cpp index 3a49bc824..74d827400 100644 --- a/src/blackcore/afv/clients/afvclient.cpp +++ b/src/blackcore/afv/clients/afvclient.cpp @@ -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 &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);