From 11275d35609af1f0bad36c82fbd2f22330a5d3ac Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 23 Sep 2019 00:30:50 +0200 Subject: [PATCH] Ref T731, connected AFV client signals with UI --- src/blackcore/context/contextaudioimpl.h | 5 ++++ .../audiodevicevolumesetupcomponent.cpp | 28 +++++++++++++++++-- .../audiodevicevolumesetupcomponent.h | 7 +++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/blackcore/context/contextaudioimpl.h b/src/blackcore/context/contextaudioimpl.h index e4a8468ab..c9af3869b 100644 --- a/src/blackcore/context/contextaudioimpl.h +++ b/src/blackcore/context/contextaudioimpl.h @@ -80,6 +80,9 @@ namespace BlackCore //! Destructor virtual ~CContextAudio() override; + //! Reference to voice client + BlackCore::Afv::Clients::CAfvClient &voiceClient() { return m_voiceClient; } + public slots: // Interface implementations //! \publicsection @@ -127,11 +130,13 @@ namespace BlackCore bool canTalk() const; BlackMisc::Aviation::CCallsignSet getRoomCallsigns(BlackMisc::Aviation::CComSystem::ComUnit comUnitValue) const; + //! @deprecated old voice @{ void initVoiceChannels(); void initInputDevice(); void initOutputDevice(); void initAudioMixer(); void initVoiceVatlib(bool allocateInput = true); + //! @} //! \copydoc IVoice::connectionStatusChanged //! \sa IContextAudio::changedVoiceRooms diff --git a/src/blackgui/components/audiodevicevolumesetupcomponent.cpp b/src/blackgui/components/audiodevicevolumesetupcomponent.cpp index 97166e90e..ac6e90299 100644 --- a/src/blackgui/components/audiodevicevolumesetupcomponent.cpp +++ b/src/blackgui/components/audiodevicevolumesetupcomponent.cpp @@ -6,9 +6,12 @@ * or distributed except according to the terms contained in the LICENSE file. */ -#include "blackcore/context/contextaudio.h" #include "blackgui/components/audiodevicevolumesetupcomponent.h" #include "blackgui/guiapplication.h" + +#include "blackcore/afv/clients/afvclient.h" +#include "blackcore/context/contextaudioimpl.h" + #include "blackmisc/audio/audiodeviceinfo.h" #include "blackmisc/audio/notificationsounds.h" #include "blackmisc/audio/audiosettings.h" @@ -23,6 +26,7 @@ #include using namespace BlackCore; +using namespace BlackCore::Afv::Clients; using namespace BlackCore::Context; using namespace BlackMisc; using namespace BlackMisc::Aviation; @@ -84,8 +88,16 @@ namespace BlackGui Q_ASSERT(c); c = connect(sGui->getIContextAudio(), &IContextAudio::changedSelectedAudioDevices, this, &CAudioDeviceVolumeSetupComponent::onCurrentAudioDevicesChanged, Qt::QueuedConnection); Q_ASSERT(c); + + if (sGui->getIContextAudio()->isUsingImplementingObject()) + { + CAfvClient &afvClient = sGui->getCoreFacade()->getCContextAudio()->voiceClient(); + connect(&afvClient, &CAfvClient::outputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onOutputVU); + connect(&afvClient, &CAfvClient::inputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onInputVU); + } + } - Q_UNUSED(c); + Q_UNUSED(c) } CAudioDeviceVolumeSetupComponent::~CAudioDeviceVolumeSetupComponent() @@ -177,7 +189,7 @@ namespace BlackGui void CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged(int v) { - Q_UNUSED(v); + Q_UNUSED(v) m_volumeSliderChanged.inputSignal(); } @@ -192,6 +204,16 @@ namespace BlackGui m_audioSettings.setAndSave(as); } + void CAudioDeviceVolumeSetupComponent::onOutputVU(double vu) + { + this->setOutLevel(qRound(vu * 100.0), 0, 100); + } + + void CAudioDeviceVolumeSetupComponent::onInputVU(double vu) + { + this->setInLevel(qRound(vu * 100.0), 0, 100); + } + void CAudioDeviceVolumeSetupComponent::onAudioDeviceSelected(int index) { if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; } diff --git a/src/blackgui/components/audiodevicevolumesetupcomponent.h b/src/blackgui/components/audiodevicevolumesetupcomponent.h index 7c97662ad..72878675f 100644 --- a/src/blackgui/components/audiodevicevolumesetupcomponent.h +++ b/src/blackgui/components/audiodevicevolumesetupcomponent.h @@ -50,8 +50,8 @@ namespace BlackGui //! @} //! Set input and output level values @{ - void setInLevel(int value, int from = BlackMisc::Audio::CSettings::InMin, int to = BlackMisc::Audio::CSettings::InMax); - void setOutLevel(int value, int from = BlackMisc::Audio::CSettings::OutMin, int to = BlackMisc::Audio::CSettings::OutMax); + void setInLevel(int value, int from, int to); + void setOutLevel(int value, int from, int to); //! @} //! Info string @@ -92,6 +92,9 @@ namespace BlackGui //! Save the audio volumes void saveVolumes(); + void onOutputVU(double vu); + void onInputVU(double vu); + QScopedPointer ui; BlackMisc::CDigestSignal m_volumeSliderChanged { this, &CAudioDeviceVolumeSetupComponent::saveVolumes, 1000, 10 }; BlackMisc::CSetting m_audioSettings { this, &CAudioDeviceVolumeSetupComponent::reloadSettings };