mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
refs #335, volume and mute functions
* refs #339, in the same step fixed delete
This commit is contained in:
committed by
Roland Winklmeier
parent
efb89dd7be
commit
e1647cd8fd
@@ -74,6 +74,16 @@ namespace BlackCore
|
|||||||
//! \details the flag indicates, whether a room got connected or disconnected
|
//! \details the flag indicates, whether a room got connected or disconnected
|
||||||
void changedVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms, bool connected);
|
void changedVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms, bool connected);
|
||||||
|
|
||||||
|
//! Volumes changed (COM1, COM2)
|
||||||
|
//! \sa setVolumes
|
||||||
|
// KB: Is see some potential changes here, which we should do when we have the new 2.0 vatlib
|
||||||
|
// 1. volume integrated in voice room?
|
||||||
|
// 2. Value object for volumes CVolume / CVolumeList?
|
||||||
|
void changedAudioVolumes(QList<qint32> volumes);
|
||||||
|
|
||||||
|
//! Mute changed
|
||||||
|
void changedMute(bool muted);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Get voice rooms for COM1, COM2:
|
//! Get voice rooms for COM1, COM2:
|
||||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const = 0;
|
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const = 0;
|
||||||
@@ -135,6 +145,12 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2) = 0;
|
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2) = 0;
|
||||||
|
|
||||||
|
//! Set the volumes (0..100)
|
||||||
|
virtual void setVolumes(qint32 volumeCom1, qint32 volumeCom2) = 0;
|
||||||
|
|
||||||
|
//! Set mute state
|
||||||
|
virtual void setMute(bool mute) = 0;
|
||||||
|
|
||||||
//! Is muted?
|
//! Is muted?
|
||||||
virtual bool isMuted() const = 0;
|
virtual bool isMuted() const = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -30,24 +30,21 @@ namespace BlackCore
|
|||||||
* Init this context
|
* Init this context
|
||||||
*/
|
*/
|
||||||
CContextAudio::CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
CContextAudio::CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||||
IContextAudio(mode, runtime), m_voice(nullptr), m_inputManager(nullptr)
|
IContextAudio(mode, runtime),
|
||||||
|
m_voice(new CVoiceVatlib())
|
||||||
{
|
{
|
||||||
// 1. Init by "voice driver"
|
// 1. Init by "voice driver"
|
||||||
this->m_voice = new CVoiceVatlib();
|
|
||||||
m_voice->moveToThread(&m_threadVoice);
|
m_voice->moveToThread(&m_threadVoice);
|
||||||
m_threadVoice.start();
|
m_threadVoice.start();
|
||||||
|
|
||||||
// 2. Register PTT hotkey function
|
// 2. Register PTT hotkey function
|
||||||
|
CVoiceVatlib *voice = m_voice.data();
|
||||||
m_inputManager = CInputManager::getInstance();
|
m_inputManager = CInputManager::getInstance();
|
||||||
m_handlePtt = m_inputManager->registerHotkeyFunc(CHotkeyFunction::Ptt(), m_voice, &CVoiceVatlib::handlePushToTalk);
|
m_handlePtt = m_inputManager->registerHotkeyFunc(CHotkeyFunction::Ptt(), voice, &CVoiceVatlib::handlePushToTalk);
|
||||||
|
|
||||||
// 3. own aircraft, if possible
|
// 3. Signal / slots
|
||||||
//if (this->getIContextOwnAircraft()) m_voice->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
connect(voice, &CVoiceVatlib::micTestFinished, this, &CContextAudio::audioTestCompleted);
|
||||||
|
connect(voice, &CVoiceVatlib::squelchTestFinished, this, &CContextAudio::audioTestCompleted);
|
||||||
// 4. Signal / slots
|
|
||||||
connect(this->m_voice, &CVoiceVatlib::micTestFinished, this, &CContextAudio::audioTestCompleted);
|
|
||||||
connect(this->m_voice, &CVoiceVatlib::squelchTestFinished, this, &CContextAudio::audioTestCompleted);
|
|
||||||
//connect(this->m_voice, &CVoiceVatlib::connectionStatusChanged, this, &CContextAudio::ps_connectionStatusChanged);
|
|
||||||
|
|
||||||
m_channelCom1 = m_voice->getVoiceChannel(0);
|
m_channelCom1 = m_voice->getVoiceChannel(0);
|
||||||
m_channelCom1->setMyAircraftCallsign(getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
m_channelCom1->setMyAircraftCallsign(getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||||
@@ -56,7 +53,7 @@ namespace BlackCore
|
|||||||
m_channelCom2->setMyAircraftCallsign(getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
m_channelCom2->setMyAircraftCallsign(getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||||
connect(m_channelCom2.data(), &IVoiceChannel::connectionStatusChanged, this, &CContextAudio::ps_com2ConnectionStatusChanged);
|
connect(m_channelCom2.data(), &IVoiceChannel::connectionStatusChanged, this, &CContextAudio::ps_com2ConnectionStatusChanged);
|
||||||
|
|
||||||
// 5. load sounds (init), not possible in own thread
|
// 4. load sounds (init), not possible in own thread
|
||||||
QTimer::singleShot(10 * 1000, this, SLOT(ps_initNotificationSounds()));
|
QTimer::singleShot(10 * 1000, this, SLOT(ps_initNotificationSounds()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,14 +175,32 @@ namespace BlackCore
|
|||||||
// volumes
|
// volumes
|
||||||
qint32 vol1 = com1.getVolumeOutput();
|
qint32 vol1 = com1.getVolumeOutput();
|
||||||
qint32 vol2 = com2.getVolumeOutput();
|
qint32 vol2 = com2.getVolumeOutput();
|
||||||
m_channelCom1->setRoomOutputVolume(vol1);
|
this->setVolumes(vol1, vol2);
|
||||||
m_channelCom2->setRoomOutputVolume(vol2);
|
|
||||||
|
|
||||||
// enable / disable in the same step
|
// enable / disable in the same step
|
||||||
m_channelCom1->switchAudioOutput(com1.isEnabled());
|
m_channelCom1->switchAudioOutput(com1.isEnabled());
|
||||||
m_channelCom2->switchAudioOutput(com2.isEnabled());
|
m_channelCom2->switchAudioOutput(com2.isEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextAudio::setVolumes(qint32 com1Volume, qint32 com2Volume)
|
||||||
|
{
|
||||||
|
if (m_channelCom1->getVolume() == com1Volume && m_channelCom2->getVolume() == com2Volume) { return; }
|
||||||
|
|
||||||
|
m_channelCom1->setRoomOutputVolume(com1Volume);
|
||||||
|
m_channelCom2->setRoomOutputVolume(com2Volume);
|
||||||
|
m_channelCom1->switchAudioOutput(com1Volume < 1);
|
||||||
|
m_channelCom2->switchAudioOutput(com2Volume < 1);
|
||||||
|
emit changedAudioVolumes(QList<qint32>({com1Volume, com2Volume}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CContextAudio::setMute(bool muted)
|
||||||
|
{
|
||||||
|
if (this->isMuted() == muted) { return; } // avoid roundtrips / unnecessary signals
|
||||||
|
m_channelCom1->switchAudioOutput(!muted);
|
||||||
|
m_channelCom2->switchAudioOutput(!muted);
|
||||||
|
emit changedMute(muted);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Muted?
|
* Muted?
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
@@ -81,6 +82,12 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextAudio::setVolumes
|
//! \copydoc IContextAudio::setVolumes
|
||||||
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2) override;
|
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2) override;
|
||||||
|
|
||||||
|
//!\copydoc IContext::setVolumes
|
||||||
|
virtual void setVolumes(qint32 com1Volume, qint32 com2Volume) override;
|
||||||
|
|
||||||
|
//! \copydoc ICOntext::setMute
|
||||||
|
virtual void setMute(bool muted) override;
|
||||||
|
|
||||||
//! \copydoc IContextAudio::isMuted()
|
//! \copydoc IContextAudio::isMuted()
|
||||||
virtual bool isMuted() const override;
|
virtual bool isMuted() const override;
|
||||||
|
|
||||||
@@ -134,8 +141,10 @@ namespace BlackCore
|
|||||||
//! Connection in transition
|
//! Connection in transition
|
||||||
bool inTransitionState() const;
|
bool inTransitionState() const;
|
||||||
|
|
||||||
CVoiceVatlib *m_voice; //!< underlying voice lib
|
// TODO: see #339, MS' comment on deletion in another thread
|
||||||
CInputManager *m_inputManager;
|
QScopedPointer<CVoiceVatlib> m_voice; //!< underlying voice lib
|
||||||
|
|
||||||
|
CInputManager *m_inputManager = nullptr;
|
||||||
CInputManager::RegistrationHandle m_handlePtt;
|
CInputManager::RegistrationHandle m_handlePtt;
|
||||||
QThread m_threadVoice;
|
QThread m_threadVoice;
|
||||||
QPointer<IVoiceChannel> m_channelCom1;
|
QPointer<IVoiceChannel> m_channelCom1;
|
||||||
|
|||||||
@@ -19,13 +19,12 @@ namespace BlackCore
|
|||||||
CContextAudioProxy::CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextAudio(mode, runtime), m_dBusInterface(nullptr)
|
CContextAudioProxy::CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextAudio(mode, runtime), m_dBusInterface(nullptr)
|
||||||
{
|
{
|
||||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||||
serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(), connection, this);
|
||||||
connection, this);
|
|
||||||
this->relaySignals(serviceName, connection);
|
this->relaySignals(serviceName, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Workaround for signals, not working without, but why?
|
* Relaying signals
|
||||||
*/
|
*/
|
||||||
void CContextAudioProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
void CContextAudioProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||||
{
|
{
|
||||||
@@ -35,6 +34,12 @@ namespace BlackCore
|
|||||||
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||||
"changedVoiceRooms", this, SIGNAL(changedVoiceRooms(BlackMisc::Audio::CVoiceRoomList, bool)));
|
"changedVoiceRooms", this, SIGNAL(changedVoiceRooms(BlackMisc::Audio::CVoiceRoomList, bool)));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
|
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||||
|
"changedAudioVolumes", this, SIGNAL(changedAudioVolumes(QList<qint32>)));
|
||||||
|
Q_ASSERT(s);
|
||||||
|
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||||
|
"changedMute", this, SIGNAL(changedMute(bool)));
|
||||||
|
Q_ASSERT(s);
|
||||||
Q_UNUSED(s);
|
Q_UNUSED(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +203,22 @@ namespace BlackCore
|
|||||||
this->m_dBusInterface->callDBus(QLatin1Literal("setVolumes"), com1, com2);
|
this->m_dBusInterface->callDBus(QLatin1Literal("setVolumes"), com1, com2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Volumes
|
||||||
|
*/
|
||||||
|
void CContextAudioProxy::setVolumes(qint32 com1Volume, qint32 com2Volume)
|
||||||
|
{
|
||||||
|
this->m_dBusInterface->callDBus(QLatin1Literal("setVolumes"), com1Volume, com2Volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Toggle mute
|
||||||
|
*/
|
||||||
|
void CContextAudioProxy::setMute(bool muted)
|
||||||
|
{
|
||||||
|
return this->m_dBusInterface->callDBus(QLatin1Literal("setMute"), muted);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Muted?
|
* Muted?
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -87,6 +87,12 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextAudio::setVolumes()
|
//! \copydoc IContextAudio::setVolumes()
|
||||||
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2) override;
|
virtual void setVolumes(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2) override;
|
||||||
|
|
||||||
|
//!\copydoc IContextAudio::setVolumes
|
||||||
|
virtual void setVolumes(qint32 com1Volume, qint32 com2Volume) override;
|
||||||
|
|
||||||
|
//! \copydoc IContextAudio::setMute
|
||||||
|
virtual void setMute(bool muted) override;
|
||||||
|
|
||||||
//! \copydoc IContextAudio::isMuted()
|
//! \copydoc IContextAudio::isMuted()
|
||||||
virtual bool isMuted() const override;
|
virtual bool isMuted() const override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user