From efee7968dc326c2389da31f17ca03257664140a4 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 16 Nov 2019 03:31:19 +0100 Subject: [PATCH] [AFV] Using the aliased frequencies can be enabled/disabled * flag * "dot command" * register audio "dot commands" for audio --- src/blackcore/afv/clients/afvclient.cpp | 3 +++ src/blackcore/afv/clients/afvclient.h | 16 ++++++++++++---- src/blackcore/context/contextaudio.cpp | 17 +++++++++++++++-- src/blackcore/context/contextaudio.h | 13 ++++++++++++- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/blackcore/afv/clients/afvclient.cpp b/src/blackcore/afv/clients/afvclient.cpp index 52d0e5624..a830c3a4a 100644 --- a/src/blackcore/afv/clients/afvclient.cpp +++ b/src/blackcore/afv/clients/afvclient.cpp @@ -1030,6 +1030,9 @@ namespace BlackCore // void rounding issues from float/double quint32 roundedFrequencyHz = static_cast(qRound(frequencyHz / 1000.0)) * 1000; + // disabled? + if (!m_enableAliased) { return roundedFrequencyHz; } + // change to aliased frequency if needed { QMutexLocker lock(&m_mutex); diff --git a/src/blackcore/afv/clients/afvclient.h b/src/blackcore/afv/clients/afvclient.h index b02b49b63..8e469aef5 100644 --- a/src/blackcore/afv/clients/afvclient.h +++ b/src/blackcore/afv/clients/afvclient.h @@ -164,6 +164,13 @@ namespace BlackCore QSet getEnabledTransceivers() const; //! @} + //! Aliased stations enabled? + //! \threadsafe + //! @{ + bool isAliasedStationsEnabled() const { return m_enableAliased; } + void enableAliasedStations(bool enabled) { m_enableAliased = enabled; } + //! @} + //! Update frequency //! \threadsafe //! @{ @@ -345,10 +352,11 @@ namespace BlackCore static const QVector &allTransceiverIds() { static const QVector transceiverIds{0, 1}; return transceiverIds; } std::atomic_int m_connectMismatches { 0 }; - std::atomic_bool m_isStarted { false }; - std::atomic_bool m_loopbackOn { false }; - std::atomic_bool m_winCoInitialized { false }; //!< Windows only CoInitializeEx - std::atomic_bool m_integratedComUnit { false }; //!< is COM unit sychronized, integrated + std::atomic_bool m_isStarted { false }; + std::atomic_bool m_loopbackOn { false }; + std::atomic_bool m_enableAliased { true }; + std::atomic_bool m_winCoInitialized { false }; //!< Windows only CoInitializeEx + std::atomic_bool m_integratedComUnit { false }; //!< is COM unit sychronized, integrated? QDateTime m_startDateTimeUtc; diff --git a/src/blackcore/context/contextaudio.cpp b/src/blackcore/context/contextaudio.cpp index fb6403631..90bca9fa5 100644 --- a/src/blackcore/context/contextaudio.cpp +++ b/src/blackcore/context/contextaudio.cpp @@ -17,6 +17,7 @@ #include "blackcore/context/contextaudioproxy.h" #include "blackmisc/simplecommandparser.h" #include "blackmisc/dbusserver.h" +#include "blackmisc/stringutils.h" #include "blackmisc/verify.h" #include "blackmisc/icons.h" #include "blackconfig/buildconfig.h" @@ -90,7 +91,8 @@ namespace BlackCore { ".vol", ".volume", // output volume ".mute", // mute - ".unmute" // unmute + ".unmute", // unmute + ".aliased" }); parser.parse(commandLine); if (!parser.isKnownCommand()) { return false; } @@ -107,8 +109,17 @@ namespace BlackCore } else if (parser.commandStartsWith("vol") && parser.countParts() > 1) { - int v = parser.toInt(1); + const int v = parser.toInt(1); this->setVoiceOutputVolume(v); + return true; + } + else if (afvClient() && parser.matchesCommand(".aliased") && parser.countParts() > 1) + { + const bool enable = parser.toBool(1, true); + afvClient()->enableAliasedStations(enable); + + CLogMessage(this).info(u"Aliased stations are: %1") << boolToOnOff(enable); + return true; } return false; } @@ -117,6 +128,8 @@ namespace BlackCore IContextAudio(mode, runtime), CIdentifiable(this) { + CContextAudioBase::registerHelp(); + if (CContextAudioBase::isNoAudioSet()) { CLogMessage(this).info(u"Voice client disabled"); diff --git a/src/blackcore/context/contextaudio.h b/src/blackcore/context/contextaudio.h index 202d3369c..30d83ea3e 100644 --- a/src/blackcore/context/contextaudio.h +++ b/src/blackcore/context/contextaudio.h @@ -33,6 +33,7 @@ #include "blackmisc/network/userlist.h" #include "blackmisc/input/actionhotkeydefs.h" #include "blackmisc/genericdbusinterface.h" +#include "blackmisc/simplecommandparser.h" #include "blackmisc/identifiable.h" #include "blackmisc/identifier.h" @@ -226,6 +227,16 @@ namespace BlackCore //! No audio? static bool isNoAudioSet(); + //! Register the commands + static void registerHelp() + { + if (BlackMisc::CSimpleCommandParser::registered("BlackCore::Context::CContextAudioBase")) { return; } + BlackMisc::CSimpleCommandParser::registerCommand({".mute", "mute audio"}); + BlackMisc::CSimpleCommandParser::registerCommand({".unmute", "unmute audio"}); + BlackMisc::CSimpleCommandParser::registerCommand({".vol volume", "volume 0..100"}); + BlackMisc::CSimpleCommandParser::registerCommand({".aliased on|off", "aliased HF frequencies"}); + } + // -------- parts which can run in core and GUI, referring to local voice client ------------ public slots: @@ -238,13 +249,13 @@ namespace BlackCore //! .mute mute BlackCore::Context::CContextAudioBase //! .unmute unmute BlackCore::Context::CContextAudioBase //! .vol .volume volume 0..100 set volume BlackCore::Context::CContextAudioBase + //! .aliased on|off aliased stations BlackCore::Context::CContextAudioBase //! virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override; //! \endcond // ------------- DBus --------------- - // ------------ local signals ------- signals: //! Audio volume changed