From 3880de5e0c4404ae28b2b6238454c3a3c93e8f49 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 12 Oct 2019 18:18:06 +0200 Subject: [PATCH] [AFV] Ref T730, added graceful shutdown in AFV client itself Also disconnect from network during "shutdown" --- src/blackcore/afv/clients/afvclient.cpp | 9 +++++++++ src/blackcore/afv/clients/afvclient.h | 3 +++ src/blackcore/context/contextaudio.cpp | 3 +-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/blackcore/afv/clients/afvclient.cpp b/src/blackcore/afv/clients/afvclient.cpp index a9fdd6fee..161ced89a 100644 --- a/src/blackcore/afv/clients/afvclient.cpp +++ b/src/blackcore/afv/clients/afvclient.cpp @@ -220,6 +220,7 @@ namespace BlackCore m_startDateTimeUtc = QDateTime::currentDateTimeUtc(); m_connection->setReceiveAudio(true); m_voiceServerPositionTimer->start(PositionUpdatesMs); + this->onSettingsChanged(); // make sure all settings are applied m_isStarted = true; CLogMessage(this).info(u"Started [Input: %1] [Output: %2]") << inputDevice.getName() << outputDevice.getName(); @@ -672,6 +673,14 @@ namespace BlackCore 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() { #ifdef _WIN32 diff --git a/src/blackcore/afv/clients/afvclient.h b/src/blackcore/afv/clients/afvclient.h index a7d9b7719..c7f06f4a5 100644 --- a/src/blackcore/afv/clients/afvclient.h +++ b/src/blackcore/afv/clients/afvclient.h @@ -221,6 +221,9 @@ namespace BlackCore //! Update the voice server URL bool updateVoiceServerUrl(const QString &url); + //! Gracefully shut down AFV client + void gracefulShutdown(); + signals: //! Receiving callsigns have been changed //! \remark callsigns I do receive diff --git a/src/blackcore/context/contextaudio.cpp b/src/blackcore/context/contextaudio.cpp index 5432ac06c..44ae3e13a 100644 --- a/src/blackcore/context/contextaudio.cpp +++ b/src/blackcore/context/contextaudio.cpp @@ -105,8 +105,7 @@ namespace BlackCore { if (m_voiceClient) { - m_voiceClient->stopAudio(); - m_voiceClient->quitAndWait(); + m_voiceClient->gracefulShutdown(); Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_voiceClient), Q_FUNC_INFO, "Needs to be back in current thread"); m_voiceClient = nullptr; }