diff --git a/src/blackcore/context_audio.h b/src/blackcore/context_audio.h index fd1425570..21fd728a5 100644 --- a/src/blackcore/context_audio.h +++ b/src/blackcore/context_audio.h @@ -127,8 +127,9 @@ namespace BlackCore /*! * \brief Play notification sound * \param notification CSoundGenerator::Notification + * \param considerSettings consider settings (notification on/off), false means settings ignored */ - virtual void playNotification(uint notification) const = 0; + virtual void playNotification(uint notification, bool considerSettings) const = 0; //! Microphone test virtual void runMicrophoneTest() = 0; diff --git a/src/blackcore/context_audio_impl.cpp b/src/blackcore/context_audio_impl.cpp index a1744afdc..64de5e129 100644 --- a/src/blackcore/context_audio_impl.cpp +++ b/src/blackcore/context_audio_impl.cpp @@ -18,6 +18,7 @@ using namespace BlackMisc; using namespace BlackMisc::Aviation; using namespace BlackMisc::Audio; using namespace BlackMisc::Hardware; +using namespace BlackSound; namespace BlackCore { @@ -26,9 +27,7 @@ namespace BlackCore * Init this context */ CContextAudio::CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : - IContextAudio(mode, runtime), - m_voice(nullptr), - m_keyboard(nullptr) + IContextAudio(mode, runtime), m_voice(nullptr), m_keyboard(nullptr) { // 1. Init by "voice driver" this->m_voice = new CVoiceVatlib(); @@ -46,6 +45,9 @@ namespace BlackCore connect(this->m_voice, &CVoiceVatlib::squelchTestFinished, this, &CContextAudio::audioTestCompleted); connect(this->m_voice, &CVoiceVatlib::connectionStatusChanged, this, &CContextAudio::connectionStatusChanged); if (this->getIContextApplication()) this->connect(this->m_voice, &IVoice::statusMessage, this->getIContextApplication(), &IContextApplication::sendStatusMessage); + + // 5. load sounds (init) + CSoundGenerator::playNotificationSound(0, CNotificationSounds::NotificationsLoadSounds); } /* @@ -188,6 +190,7 @@ namespace BlackCore Q_ASSERT(this->m_voice); Q_ASSERT(newRooms.size() == 2); if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, newRooms.toQString()); + CVoiceRoomList currentRooms = this->m_voice->getComVoiceRooms(); CVoiceRoom currentRoom1 = currentRooms[0]; CVoiceRoom currentRoom2 = currentRooms[1]; @@ -275,11 +278,19 @@ namespace BlackCore /* * Notification */ - void CContextAudio::playNotification(uint notification) const + void CContextAudio::playNotification(uint notification, bool considerSettings) const { Q_ASSERT(this->m_voice); if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, QString::number(notification)); - BlackSound::CSoundGenerator::playNotificationSound(90, static_cast(notification)); + + BlackSound::CNotificationSounds::Notification notificationSound = static_cast(notification); + if (considerSettings) + { + Q_ASSERT(this->getIContextSettings()); + bool play = this->getIContextSettings()->getAudioSettings().getNotificationFlag(notificationSound); + if (!play) return; + } + BlackSound::CSoundGenerator::playNotificationSound(90, notificationSound); } /* @@ -322,6 +333,9 @@ namespace BlackCore return static_cast(this->m_voice->inputSquelch()); } + /* + * Audio loopback + */ void CContextAudio::enableAudioLoopback(bool enable) { Q_ASSERT(this->m_voice); diff --git a/src/blackcore/context_audio_impl.h b/src/blackcore/context_audio_impl.h index 894380c24..7547de191 100644 --- a/src/blackcore/context_audio_impl.h +++ b/src/blackcore/context_audio_impl.h @@ -14,6 +14,7 @@ #include "blackcore/keyboard.h" #include +#include namespace BlackCore { @@ -80,7 +81,7 @@ namespace BlackCore virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const override; //! \copydoc IContextAudio::playNotification() - virtual void playNotification(uint notification) const override; + virtual void playNotification(uint notification, bool considerSettings) const override; //! \copydoc IContextAudio::runMicrophoneTest() virtual void runMicrophoneTest() override; @@ -118,6 +119,9 @@ namespace BlackCore void connectionStatusChanged(IVoice::ComUnit comUnit, IVoice::ConnectionStatus oldStatus, IVoice::ConnectionStatus newStatus); private: + //! Connection in transition + bool inTransitionState() const; + CVoiceVatlib *m_voice; //!< underlying voice lib IKeyboard *m_keyboard; IKeyboard::RegistrationHandle m_handlePtt; diff --git a/src/blackcore/context_audio_proxy.cpp b/src/blackcore/context_audio_proxy.cpp index 8c342cc1e..f2f8b3b3f 100644 --- a/src/blackcore/context_audio_proxy.cpp +++ b/src/blackcore/context_audio_proxy.cpp @@ -153,9 +153,9 @@ namespace BlackCore /* * Notification sound */ - void CContextAudioProxy::playNotification(uint notification) const + void CContextAudioProxy::playNotification(uint notification, bool considerSettings) const { - this->m_dBusInterface->callDBus(QLatin1Literal("playNotification"), notification); + this->m_dBusInterface->callDBus(QLatin1Literal("playNotification"), notification, considerSettings); } /* diff --git a/src/blackcore/context_audio_proxy.h b/src/blackcore/context_audio_proxy.h index 27074eb6d..cb5cb728d 100644 --- a/src/blackcore/context_audio_proxy.h +++ b/src/blackcore/context_audio_proxy.h @@ -89,11 +89,11 @@ namespace BlackCore //! \copydoc IContextAudio::isMuted() virtual bool isMuted() const override; - //! \copydoc IContextAudio::playSelcalTone() + //! \copydoc IContextAudio::playSelcalTone virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const override; - //! \copydoc IContextAudio::playNotification() - virtual void playNotification(uint notification) const override; + //! \copydoc IContextAudio::playNotification + virtual void playNotification(uint notification, bool considerSettings) const override; //! \copydoc IContextAudio::runMicrophoneTest() virtual void runMicrophoneTest() override;