[AFV] restart function

This commit is contained in:
Klaus Basan
2020-01-22 20:02:01 +01:00
parent 5f6912e814
commit c46ca3c616
2 changed files with 21 additions and 2 deletions

View File

@@ -203,7 +203,7 @@ namespace BlackCore
{
// 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) disconnectFrom(stop); });
QMetaObject::invokeMethod(this, [ = ]() { if (myself) { disconnectFrom(stop); }});
return;
}
@@ -260,7 +260,8 @@ namespace BlackCore
if (QThread::currentThread() != this->thread())
{
// Method needs to be executed in the object thread since it will create new QObject children
QMetaObject::invokeMethod(this, [ = ]() { startAudio(inputDevice, outputDevice); });
QPointer<CAfvClient> myself(this);
QMetaObject::invokeMethod(this, [ = ]() { if (myself) { startAudio(inputDevice, outputDevice); }});
return;
}
@@ -364,6 +365,23 @@ namespace BlackCore
emit this->stoppedAudio();
}
void CAfvClient::restartAudio()
{
if (!m_isStarted)
{
// just need to start
this->startAudio();
return;
}
this->stopAudio();
QPointer<CAfvClient> myself(this);
QTimer::singleShot(1000, this, [ = ]
{
if (myself) { myself->startAudio(); }
});
}
double CAfvClient::getDeviceInputVolume() const
{
if (m_input) { return m_input->getDeviceInputVolume(); }

View File

@@ -126,6 +126,7 @@ namespace BlackCore
void startAudio(const BlackMisc::Audio::CAudioDeviceInfo &inputDevice, const BlackMisc::Audio::CAudioDeviceInfo &outputDevice);
Q_INVOKABLE void startAudio(const QString &inputDeviceName, const QString &outputDeviceName);
void stopAudio();
void restartAudio();
//! @}
//! The device's volume 0..1 @{