refs #258, notification sound for voice rooms in context

This commit is contained in:
Klaus Basan
2014-06-05 03:00:13 +02:00
parent 21b88b373e
commit e823f87bab
5 changed files with 31 additions and 12 deletions

View File

@@ -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;

View File

@@ -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<BlackSound::CNotificationSounds::Notification>(notification));
BlackSound::CNotificationSounds::Notification notificationSound = static_cast<BlackSound::CNotificationSounds::Notification>(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<double>(this->m_voice->inputSquelch());
}
/*
* Audio loopback
*/
void CContextAudio::enableAudioLoopback(bool enable)
{
Q_ASSERT(this->m_voice);

View File

@@ -14,6 +14,7 @@
#include "blackcore/keyboard.h"
#include <QThread>
#include <QQueue>
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;

View File

@@ -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);
}
/*

View File

@@ -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;