[AFV] Hide AFV client behind context

This commit is contained in:
Roland Rossgotterer
2019-10-10 15:57:56 +02:00
committed by Mat Sutcliffe
parent 90e5400049
commit 01d144b528
7 changed files with 64 additions and 66 deletions

View File

@@ -168,25 +168,17 @@ namespace BlackCore
this->setNormalizedOutputVolume(mute ? 0 : 50);
}
bool CAfvClient::restartWithNewDevices(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice)
void CAfvClient::restartWithNewDevices(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice)
{
if (!m_isStarted)
{
this->startAudio(inputDevice, outputDevice, allTransceiverIds());
return true;
}
if (QThread::currentThread() != this->thread())
{
// Method needs to be executed in the object thread since it will create new QObject children
QPointer<CAfvClient> myself(this);
QMetaObject::invokeMethod(this, [ = ]() { if (myself) restartWithNewDevices(inputDevice, outputDevice); });
return true;
}
this->stopAudio();
if (m_isStarted) { this->stopAudio(); }
this->startAudio(inputDevice, outputDevice, allTransceiverIds());
return true;
}
void CAfvClient::startAudio(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice, const QVector<quint16> &transceiverIDs)