mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
[AFV] restart function
This commit is contained in:
@@ -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(); }
|
||||
|
||||
@@ -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 @{
|
||||
|
||||
Reference in New Issue
Block a user