[AFV] Ref T730, added graceful shutdown in AFV client itself

Also disconnect from network during "shutdown"
This commit is contained in:
Klaus Basan
2019-10-12 18:18:06 +02:00
parent d2de52f818
commit 3880de5e0c
3 changed files with 13 additions and 2 deletions

View File

@@ -220,6 +220,7 @@ namespace BlackCore
m_startDateTimeUtc = QDateTime::currentDateTimeUtc(); m_startDateTimeUtc = QDateTime::currentDateTimeUtc();
m_connection->setReceiveAudio(true); m_connection->setReceiveAudio(true);
m_voiceServerPositionTimer->start(PositionUpdatesMs); m_voiceServerPositionTimer->start(PositionUpdatesMs);
this->onSettingsChanged(); // make sure all settings are applied this->onSettingsChanged(); // make sure all settings are applied
m_isStarted = true; m_isStarted = true;
CLogMessage(this).info(u"Started [Input: %1] [Output: %2]") << inputDevice.getName() << outputDevice.getName(); CLogMessage(this).info(u"Started [Input: %1] [Output: %2]") << inputDevice.getName() << outputDevice.getName();
@@ -672,6 +673,14 @@ namespace BlackCore
return m_connection->updateVoiceServerUrl(url); return m_connection->updateVoiceServerUrl(url);
} }
void CAfvClient::gracefulShutdown()
{
this->stopAudio();
this->disconnectFrom();
this->quitAndWait();
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Needs to be back in current thread");
}
void CAfvClient::initialize() void CAfvClient::initialize()
{ {
#ifdef _WIN32 #ifdef _WIN32

View File

@@ -221,6 +221,9 @@ namespace BlackCore
//! Update the voice server URL //! Update the voice server URL
bool updateVoiceServerUrl(const QString &url); bool updateVoiceServerUrl(const QString &url);
//! Gracefully shut down AFV client
void gracefulShutdown();
signals: signals:
//! Receiving callsigns have been changed //! Receiving callsigns have been changed
//! \remark callsigns I do receive //! \remark callsigns I do receive

View File

@@ -105,8 +105,7 @@ namespace BlackCore
{ {
if (m_voiceClient) if (m_voiceClient)
{ {
m_voiceClient->stopAudio(); m_voiceClient->gracefulShutdown();
m_voiceClient->quitAndWait();
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_voiceClient), Q_FUNC_INFO, "Needs to be back in current thread"); Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_voiceClient), Q_FUNC_INFO, "Needs to be back in current thread");
m_voiceClient = nullptr; m_voiceClient = nullptr;
} }