From a475d12339673c2cf655cda6b8ff18b65230fd30 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 28 Sep 2018 05:08:49 +0200 Subject: [PATCH] Ref T376, voice (vatlib) getter/setter for CVoiceSetup --- src/blackcore/vatsim/voicevatlib.cpp | 20 +++++++++++++++++--- src/blackcore/vatsim/voicevatlib.h | 17 +++++++++++------ src/blackcore/voice.h | 7 +++++++ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/blackcore/vatsim/voicevatlib.cpp b/src/blackcore/vatsim/voicevatlib.cpp index fcc4d737d..3a4475a38 100644 --- a/src/blackcore/vatsim/voicevatlib.cpp +++ b/src/blackcore/vatsim/voicevatlib.cpp @@ -35,10 +35,11 @@ namespace BlackCore CVoiceVatlib::CVoiceVatlib(QObject *parent) : IVoice(parent), - m_audioService(Vat_CreateAudioService()), - m_udpPort(Vat_CreateUDPAudioPort(m_audioService.data(), m_vatsimVoicePortSetting.getThreadLocal())) + m_audioService(Vat_CreateAudioService()) { + const int udpPort = m_vatsimVoiceSettings.get().getVatsimUdpVoicePort(); Vat_SetVoiceLogHandler(SeverityLevel::SeverityError, CVoiceVatlib::voiceLogHandler); + m_udpPort.reset(Vat_CreateUDPAudioPort(m_audioService.data(), udpPort)); // do processing this->startTimer(10); @@ -46,6 +47,19 @@ namespace BlackCore CVoiceVatlib::~CVoiceVatlib() {} + void CVoiceVatlib::setVoiceSetup(const CVoiceSetup &setup) + { + if (m_vatsimVoiceSettings.get() == setup) { return; } + m_vatsimVoiceSettings.setAndSave(setup); + + // CHANGE VOICE PORT WOULD NEED TO GO HERE + } + + CVoiceSetup CVoiceVatlib::getVoiceSetup() const + { + return m_vatsimVoiceSettings.get(); + } + QSharedPointer CVoiceVatlib::createVoiceChannel() { return QSharedPointer(new CVoiceChannelVatlib(m_audioService.data(), m_udpPort.data(), this)); @@ -143,7 +157,7 @@ namespace BlackCore void CVoiceVatlib::voiceLogHandler(SeverityLevel /** severity **/, const char *context, const char *message) { - QString errorMessage ("vatlib "); + QString errorMessage("vatlib "); errorMessage += context; errorMessage += ": "; errorMessage += message; diff --git a/src/blackcore/vatsim/voicevatlib.h b/src/blackcore/vatsim/voicevatlib.h index 57ab04c92..63d85fab8 100644 --- a/src/blackcore/vatsim/voicevatlib.h +++ b/src/blackcore/vatsim/voicevatlib.h @@ -12,12 +12,13 @@ #ifndef BLACKCORE_VOICE_VATLIB_H #define BLACKCORE_VOICE_VATLIB_H -#include "blackcore/audio/audiosettings.h" #include "blackcore/audiomixer.h" #include "blackcore/blackcoreexport.h" #include "blackcore/voice.h" +#include "blackmisc/audio/settings/voicesettings.h" #include "blackmisc/logcategorylist.h" #include + #include #include #include @@ -33,7 +34,7 @@ template class QSharedPointer; #ifndef NOMINMAX #define NOMINMAX #endif -#include +#include #endif namespace BlackCore @@ -57,7 +58,13 @@ namespace BlackCore CVoiceVatlib(QObject *parent = nullptr); //! Destructor - virtual ~CVoiceVatlib(); + virtual ~CVoiceVatlib() override; + + //! \copydoc IVoice::setVoiceSetup() + virtual void setVoiceSetup(const BlackMisc::Audio::CVoiceSetup &setup) override; + + //! \copydoc IVoice::getVoiceSetup() + virtual BlackMisc::Audio::CVoiceSetup getVoiceSetup() const override; //! \copydoc IVoice::createVoiceChannel() virtual QSharedPointer createVoiceChannel() override; @@ -117,9 +124,7 @@ namespace BlackCore static void voiceLogHandler(SeverityLevel severity, const char *context, const char *message); - // settings - BlackMisc::CSettingReadOnly m_vatsimVoicePortSetting { this }; - + BlackMisc::CSetting m_vatsimVoiceSettings { this }; QScopedPointer m_audioService; QScopedPointer m_udpPort; }; diff --git a/src/blackcore/voice.h b/src/blackcore/voice.h index 826396e1f..8164c1b31 100644 --- a/src/blackcore/voice.h +++ b/src/blackcore/voice.h @@ -12,6 +12,7 @@ #include "blackcore/audiomixer.h" #include "blackcore/blackcoreexport.h" +#include "blackmisc/audio/voicesetup.h" #include #include @@ -39,6 +40,12 @@ namespace BlackCore //! Virtual destructor. virtual ~IVoice() {} + //! Set voice setup + virtual void setVoiceSetup(const BlackMisc::Audio::CVoiceSetup &setup) = 0; + + //! Get voice setup + virtual BlackMisc::Audio::CVoiceSetup getVoiceSetup() const = 0; + //! Create voice channel object virtual QSharedPointer createVoiceChannel() = 0;