mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #246, removed own aircraft from context
* refactored method set voice rooms * signal changed voice rooms
This commit is contained in:
@@ -54,15 +54,10 @@ namespace BlackCore
|
||||
//! \brief Audio test has been completed
|
||||
void audioTestCompleted();
|
||||
|
||||
//! Voice rooms changed
|
||||
void changedVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms);
|
||||
|
||||
public slots:
|
||||
|
||||
/*!
|
||||
* Set my own identity for the voice rooms.
|
||||
* \remarks Actually at this time the callsign alone was sufficient. But pass the
|
||||
* whole aircraft object so further information are present if needed any time later.
|
||||
*/
|
||||
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAiricraft) = 0;
|
||||
|
||||
//! Get voice rooms for COM1, COM2:
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRoomsWithAudioStatus() const = 0;
|
||||
|
||||
@@ -84,7 +79,7 @@ namespace BlackCore
|
||||
virtual BlackMisc::Audio::CVoiceRoom getCom2VoiceRoom(bool withAudioStatus) const = 0;
|
||||
|
||||
//! Set voice rooms
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoom &voiceRoomCom1, const BlackMisc::Audio::CVoiceRoom &voiceRoomCom2) = 0;
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms) = 0;
|
||||
|
||||
//! Leave all voice rooms
|
||||
virtual void leaveAllVoiceRooms() = 0;
|
||||
|
||||
@@ -5,13 +5,15 @@
|
||||
|
||||
#include "context_audio_impl.h"
|
||||
#include "context_network.h"
|
||||
#include "context_ownaircraft.h"
|
||||
#include "context_application.h"
|
||||
|
||||
#include "blacksound/soundgenerator.h"
|
||||
#include "blackmisc/notificationsounds.h"
|
||||
#include "blackmisc/voiceroomlist.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Audio;
|
||||
@@ -33,11 +35,17 @@ namespace BlackCore
|
||||
m_voice->moveToThread(&m_threadVoice);
|
||||
m_threadVoice.start();
|
||||
|
||||
// 2. Hotkeys
|
||||
m_keyboard = IKeyboard::getInstance();
|
||||
|
||||
// 2. Signal / slots
|
||||
// 3. own aircraft, if possible
|
||||
if (this->getIContextOwnAircraft()) m_voice->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
|
||||
// 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::connectionStatusChanged);
|
||||
if (this->getIContextApplication()) this->connect(this->m_voice, &IVoice::statusMessage, this->getIContextApplication(), &IContextApplication::sendStatusMessage);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -50,16 +58,6 @@ namespace BlackCore
|
||||
m_threadVoice.wait(1000);
|
||||
}
|
||||
|
||||
/*
|
||||
* Own aircraft
|
||||
*/
|
||||
void CContextAudio::setOwnAircraft(const CAircraft &ownAircraft)
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, ownAircraft.toQString());
|
||||
this->m_voice->setMyAircraftCallsign(ownAircraft.getCallsign());
|
||||
}
|
||||
|
||||
/*
|
||||
* Voice rooms for COM
|
||||
*/
|
||||
@@ -80,7 +78,7 @@ namespace BlackCore
|
||||
if (withAudioStatus)
|
||||
return this->m_voice->getComVoiceRoomsWithAudioStatus()[0];
|
||||
else
|
||||
return this->m_voice->getComVoiceRooms()[1];
|
||||
return this->m_voice->getComVoiceRooms()[0];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -164,8 +162,10 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, com1.toQString(), com2.toQString());
|
||||
this->m_voice->setRoomOutputVolume(IVoice::COM1, com1.getVolumeOutput());
|
||||
this->m_voice->setRoomOutputVolume(IVoice::COM2, com2.getVolumeOutput());
|
||||
qint32 vol1 = com1.getVolumeOutput();
|
||||
qint32 vol2 = com2.getVolumeOutput();
|
||||
this->m_voice->setRoomOutputVolume(IVoice::COM1, vol1);
|
||||
this->m_voice->setRoomOutputVolume(IVoice::COM2, vol2);
|
||||
this->m_voice->switchAudioOutput(IVoice::COM1, com1.isEnabled());
|
||||
this->m_voice->switchAudioOutput(IVoice::COM2, com2.isEnabled());
|
||||
}
|
||||
@@ -183,23 +183,36 @@ namespace BlackCore
|
||||
/*
|
||||
* Set voice rooms
|
||||
*/
|
||||
void CContextAudio::setComVoiceRooms(const CVoiceRoom &voiceRoomCom1, const CVoiceRoom &voiceRoomCom2)
|
||||
void CContextAudio::setComVoiceRooms(const CVoiceRoomList &newRooms)
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, voiceRoomCom1.toQString(), voiceRoomCom2.toQString());
|
||||
CVoiceRoomList currentRooms = this->m_voice->getComVoiceRoomsWithAudioStatus();
|
||||
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];
|
||||
if (currentRoom1 != voiceRoomCom1)
|
||||
CVoiceRoom newRoom1 = newRooms[0];
|
||||
CVoiceRoom newRoom2 = newRooms[1];
|
||||
|
||||
bool changed = false;
|
||||
|
||||
// changed rooms? But only compare on "URL", not status as connected etc.
|
||||
if (currentRoom1.getVoiceRoomUrl() != newRoom1.getVoiceRoomUrl())
|
||||
{
|
||||
if (currentRoom1.isValid()) this->m_voice->leaveVoiceRoom(IVoice::COM1);
|
||||
if (voiceRoomCom1.isValid()) this->m_voice->joinVoiceRoom(IVoice::COM1, voiceRoomCom1);
|
||||
this->m_voice->leaveVoiceRoom(IVoice::COM1);
|
||||
if (newRoom1.isValid()) this->m_voice->joinVoiceRoom(IVoice::COM1, newRoom1);
|
||||
changed = true;
|
||||
}
|
||||
if (currentRoom2 != voiceRoomCom2)
|
||||
if (currentRoom2.getVoiceRoomUrl() != newRoom2.getVoiceRoomUrl())
|
||||
{
|
||||
if (currentRoom2.isValid()) this->m_voice->leaveVoiceRoom(IVoice::COM2);
|
||||
if (voiceRoomCom2.isValid()) this->m_voice->joinVoiceRoom(IVoice::COM2, voiceRoomCom2);
|
||||
this->m_voice->leaveVoiceRoom(IVoice::COM2);
|
||||
if (newRoom2.isValid()) this->m_voice->joinVoiceRoom(IVoice::COM2, newRoom2);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// changed not yet used, but I keep it for debugging
|
||||
// changedVoiceRooms called by connectionStatusChanged;
|
||||
Q_UNUSED(changed);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -209,7 +222,9 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
return this->m_voice->getVoiceRoomCallsigns(IVoice::COM1);
|
||||
CCallsignList callsigns = this->m_voice->getVoiceRoomCallsigns(IVoice::COM1);
|
||||
qDebug() << "1" << callsigns;
|
||||
return callsigns;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -219,7 +234,9 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
return this->m_voice->getVoiceRoomCallsigns(IVoice::COM2);
|
||||
CCallsignList callsigns = this->m_voice->getVoiceRoomCallsigns(IVoice::COM2);
|
||||
qDebug() << "2" << callsigns;
|
||||
return callsigns;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -243,7 +260,7 @@ namespace BlackCore
|
||||
Q_ASSERT(this->getRuntime());
|
||||
if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList();
|
||||
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
return this->getRuntime()->getIContextNetwork()->getUsersForCallsigns(this->getCom2RoomCallsigns());
|
||||
return this->getIContextNetwork()->getUsersForCallsigns(this->getCom2RoomCallsigns());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -319,6 +336,7 @@ namespace BlackCore
|
||||
*/
|
||||
void CContextAudio::settingsChanged(uint typeValue)
|
||||
{
|
||||
if (this->getIContextOwnAircraft()) m_voice->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
if (!this->getIContextSettings()) return;
|
||||
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue);
|
||||
if (type == IContextSettings::SettingsHotKeys)
|
||||
@@ -331,4 +349,27 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Connection status changed
|
||||
*/
|
||||
void CContextAudio::connectionStatusChanged(IVoice::ComUnit comUnit, IVoice::ConnectionStatus oldStatus, IVoice::ConnectionStatus newStatus)
|
||||
{
|
||||
Q_UNUSED(comUnit);
|
||||
Q_UNUSED(oldStatus);
|
||||
|
||||
switch (newStatus)
|
||||
{
|
||||
case IVoice::Connected:
|
||||
emit this->changedVoiceRooms(this->m_voice->getComVoiceRooms());
|
||||
break;
|
||||
case IVoice::Disconnecting:
|
||||
emit this->changedVoiceRooms(this->m_voice->getComVoiceRooms());
|
||||
// good chance to update aircraft
|
||||
if (this->getIContextOwnAircraft()) m_voice->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
//! \brief Audio context implementation
|
||||
//! Audio context implementation
|
||||
class CContextAudio : public IContextAudio
|
||||
{
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
|
||||
@@ -27,13 +27,10 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
|
||||
//! \brief Destructor
|
||||
//! Destructor
|
||||
virtual ~CContextAudio();
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextAudio::setOwnAircraft()
|
||||
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAircraft) override;
|
||||
|
||||
//! \copydoc IContextAudio::getComVoiceRooms()
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const override;
|
||||
|
||||
@@ -46,8 +43,8 @@ namespace BlackCore
|
||||
//! \copydoc IContextAudio::getCom2VoiceRoom
|
||||
virtual BlackMisc::Audio::CVoiceRoom getCom2VoiceRoom(bool withAudioStatus) const override;
|
||||
|
||||
//! \copydoc IContextAudio::setComVoiceRooms()
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoom &voiceRoomCom1, const BlackMisc::Audio::CVoiceRoom &voiceRoomCom2) override;
|
||||
//! \copydoc IContextAudio::setComVoiceRooms
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &newRooms) override;
|
||||
|
||||
//! \copydoc IContextAudio::getCom1RoomCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom1RoomCallsigns() const override;
|
||||
@@ -101,10 +98,10 @@ namespace BlackCore
|
||||
virtual void enableAudioLoopback(bool enable = true) override;
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
//! Constructor
|
||||
CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
|
||||
//! \brief Register myself in DBus
|
||||
//! Register myself in DBus
|
||||
CContextAudio *registerWithDBus(CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) return this;
|
||||
@@ -113,8 +110,13 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
private slots:
|
||||
//! Settings have been changed
|
||||
void settingsChanged(uint typeValue);
|
||||
|
||||
//! \copydoc IVoice::connectionStatusChanged
|
||||
//! \sa IContextAudio::changedVoiceRooms
|
||||
void connectionStatusChanged(IVoice::ComUnit comUnit, IVoice::ConnectionStatus oldStatus, IVoice::ConnectionStatus newStatus);
|
||||
|
||||
private:
|
||||
CVoiceVatlib *m_voice; //!< underlying voice lib
|
||||
IKeyboard *m_keyboard;
|
||||
|
||||
@@ -32,17 +32,12 @@ namespace BlackCore
|
||||
bool s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||
"audioTestCompleted", this, SIGNAL(audioTestCompleted()));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
|
||||
"changedVoiceRooms", this, SIGNAL(changedVoiceRooms(BlackMisc::Audio::CVoiceRoomList)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Own aircraft
|
||||
*/
|
||||
void CContextAudioProxy::setOwnAircraft(const CAircraft &ownAircraft)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setOwnAircraft"), ownAircraft);
|
||||
}
|
||||
|
||||
/*
|
||||
* Leave all voice rooms
|
||||
*/
|
||||
@@ -142,9 +137,9 @@ namespace BlackCore
|
||||
/*
|
||||
* Set voice rooms
|
||||
*/
|
||||
void CContextAudioProxy::setComVoiceRooms(const BlackMisc::Audio::CVoiceRoom &voiceRoomCom1, const BlackMisc::Audio::CVoiceRoom &voiceRoomCom2)
|
||||
void CContextAudioProxy::setComVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setComVoiceRooms"), voiceRoomCom1, voiceRoomCom2);
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setComVoiceRooms"), voiceRooms);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -44,10 +44,6 @@ namespace BlackCore
|
||||
CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
|
||||
public slots:
|
||||
|
||||
//! \copydoc IContextAudio::setOwnAircraft()
|
||||
virtual void setOwnAircraft(const BlackMisc::Aviation::CAircraft &ownAircraft) override;
|
||||
|
||||
//! \copydoc IContextAudio::getComVoiceRooms()
|
||||
virtual BlackMisc::Audio::CVoiceRoomList getComVoiceRooms() const override;
|
||||
|
||||
@@ -61,7 +57,7 @@ namespace BlackCore
|
||||
virtual BlackMisc::Audio::CVoiceRoom getCom2VoiceRoom(bool withAudioStatus) const override;
|
||||
|
||||
//! \copydoc IContextAudio::setComVoiceRooms()
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoom &voiceRoomCom1, const BlackMisc::Audio::CVoiceRoom &voiceRoomCom2) override;
|
||||
virtual void setComVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms) override;
|
||||
|
||||
//! \copydoc IContextAudio::getCom1RoomCallsigns()
|
||||
virtual BlackMisc::Aviation::CCallsignList getCom1RoomCallsigns() const override;
|
||||
|
||||
Reference in New Issue
Block a user