mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Changed voice context so it can play SELCAL tones. This makes sense, as I can
use the device information of this context. Sound shall be played on the same computer as the voice. * Adjusted .pro file * Methods for SELCAL in context * New XML file (DBus) * changed the place where I can obtain the current in/output device
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f9225814f9
commit
6485527062
@@ -56,13 +56,17 @@
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Voice::CAudioDevice"/>
|
||||
</method>
|
||||
<method name="setVolumes">
|
||||
<arg name="com1" type="(s(dd(s))(dd(s))iiib)" direction="in"/>
|
||||
<arg name="com1" type="(s(dd(s))(dd(s))iiibu)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CComSystem"/>
|
||||
<arg name="com2" type="(s(dd(s))(dd(s))iiib)" direction="in"/>
|
||||
<arg name="com2" type="(s(dd(s))(dd(s))iiibu)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="BlackMisc::Aviation::CComSystem"/>
|
||||
</method>
|
||||
<method name="isMuted">
|
||||
<arg type="b" direction="out"/>
|
||||
</method>
|
||||
<method name="playSelcalTone">
|
||||
<arg name="selcal" type="(s)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="BlackMisc::Aviation::CSelcal"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
|
||||
@@ -2,7 +2,7 @@ include (../../externals.pri)
|
||||
|
||||
# GUI is required for the matrix classes
|
||||
# Network for host info etc.
|
||||
QT += network dbus xml
|
||||
QT += network dbus xml multimedia
|
||||
|
||||
TARGET = blackcore
|
||||
TEMPLATE = lib
|
||||
@@ -23,6 +23,7 @@ precompile_header:!isEmpty(PRECOMPILED_HEADER) {
|
||||
# !! Make sure the plugin is available as release build and known QT_PLUGIN_PATH
|
||||
QDBUSXML2CPP_ADAPTOR_HEADER_FLAGS = -i blackmisc/blackmiscfreefunctions.h -i blackmisc/blackmiscallvalueclasses.h
|
||||
DBUS_ADAPTORS += blackcore.contextnetwork.xml
|
||||
DBUS_ADAPTORS += blackcore.contextvoice.xml
|
||||
DBUS_ADAPTORS += blackcore.contextsettings.xml
|
||||
DBUS_ADAPTORS += blackcore.contextapplication.xml
|
||||
|
||||
@@ -34,8 +35,8 @@ DEFINES += LOG_IN_FILE
|
||||
HEADERS += *.h
|
||||
SOURCES += *.cpp
|
||||
|
||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib
|
||||
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a
|
||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib ../../lib/blacksound.lib
|
||||
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a ../../libblacksound.a
|
||||
|
||||
DESTDIR = ../../lib
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "context_voice.h"
|
||||
#include "context_network.h"
|
||||
#include "coreruntime.h"
|
||||
|
||||
#include "../blacksound/soundgenerator.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -18,15 +18,12 @@ namespace BlackCore
|
||||
/*
|
||||
* Init this context
|
||||
*/
|
||||
CContextVoice::CContextVoice(CCoreRuntime *runtime) :
|
||||
IContextVoice(runtime), m_voice(nullptr), m_currentInputDevice(), m_currentOutputDevice()
|
||||
CContextVoice::CContextVoice(CCoreRuntime *runtime) : IContextVoice(runtime), m_voice(nullptr)
|
||||
{
|
||||
Q_ASSERT(runtime);
|
||||
|
||||
// 1. Init by "network driver"
|
||||
this->m_voice = new CVoiceVatlib(this);
|
||||
this->m_currentInputDevice = this->m_voice->defaultAudioInputDevice();
|
||||
this->m_currentOutputDevice = this->m_voice->defaultAudioOutputDevice();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -104,8 +101,8 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
CAudioDeviceList devices;
|
||||
devices.push_back(this->m_currentInputDevice);
|
||||
devices.push_back(this->m_currentOutputDevice);
|
||||
devices.push_back(this->m_voice->getCurrentInputDevice());
|
||||
devices.push_back(this->m_voice->getCurrentOutputDevice());
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -119,12 +116,10 @@ namespace BlackCore
|
||||
if (audioDevice.getType() == CAudioDevice::InputDevice)
|
||||
{
|
||||
this->m_voice->setInputDevice(audioDevice);
|
||||
this->m_currentInputDevice = audioDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_voice->setOutputDevice(audioDevice);
|
||||
this->m_currentOutputDevice = audioDevice;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +196,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
/*
|
||||
* Room 1 users
|
||||
* Room 2 users
|
||||
*/
|
||||
Network::CUserList CContextVoice::getCom2RoomUsers() const
|
||||
{
|
||||
@@ -212,4 +207,13 @@ namespace BlackCore
|
||||
getUsersForCallsigns(this->getCom2RoomCallsigns());
|
||||
}
|
||||
|
||||
/*
|
||||
* SELCAL tone
|
||||
*/
|
||||
void CContextVoice::playSelcalTone(const CSelcal &selcal) const
|
||||
{
|
||||
Q_ASSERT(this->m_voice);
|
||||
CAudioDevice outputDevice = m_voice->getCurrentOutputDevice();
|
||||
BlackSound::CSoundGenerator::playSelcal(90, selcal, outputDevice);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -146,10 +146,14 @@ namespace BlackCore
|
||||
*/
|
||||
virtual bool isMuted() const;
|
||||
|
||||
/*!
|
||||
* \brief Play selcal tone
|
||||
* \param selcal
|
||||
*/
|
||||
virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const;
|
||||
|
||||
private:
|
||||
CVoiceVatlib *m_voice; //!< underlying voice lib
|
||||
BlackMisc::Voice::CAudioDevice m_currentInputDevice; //!< input device
|
||||
BlackMisc::Voice::CAudioDevice m_currentOutputDevice; //!< current output device
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
using namespace BlackMisc::Voice;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -86,6 +87,14 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<CAudioDeviceList>(QLatin1Literal("getCurrentAudioDevices"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set current audio device
|
||||
*/
|
||||
void IContextVoice::setCurrentAudioDevice(const CAudioDevice &audioDevice)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setCurrentAudioDevice"), audioDevice);
|
||||
}
|
||||
|
||||
/*
|
||||
* Voice rooms, with audio status
|
||||
*/
|
||||
@@ -127,11 +136,11 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
/*
|
||||
* Set current audio device
|
||||
* Play SELCAL tone
|
||||
*/
|
||||
void IContextVoice::setCurrentAudioDevice(const CAudioDevice &audioDevice)
|
||||
void IContextVoice::playSelcalTone(const CSelcal &selcal) const
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("setCurrentAudioDevice"), audioDevice);
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("playSelcalTone"), selcal);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -187,6 +187,10 @@ namespace BlackCore
|
||||
*/
|
||||
virtual bool isMuted() const;
|
||||
|
||||
/*!
|
||||
* \brief Play SELCAL tone
|
||||
*/
|
||||
virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "../blackmisc/context.h"
|
||||
#include "../blackmisc/avcallsignlist.h"
|
||||
#include "../blackmisc/avselcal.h"
|
||||
#include "../blackmisc/nwuserlist.h"
|
||||
#include "../blackmisc/vvoiceroomlist.h"
|
||||
#include "../blackmisc/vaudiodevicelist.h"
|
||||
@@ -117,15 +118,25 @@ namespace BlackCore
|
||||
public slots:
|
||||
|
||||
/*!
|
||||
* \brief Input device to be used
|
||||
* \brief Current input device
|
||||
*/
|
||||
virtual void setInputDevice(const BlackMisc::Voice::CAudioDevice &device) = 0;
|
||||
virtual BlackMisc::Voice::CAudioDevice getCurrentInputDevice() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Current output device
|
||||
*/
|
||||
virtual BlackMisc::Voice::CAudioDevice getCurrentOutputDevice() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Output device to be used
|
||||
*/
|
||||
virtual void setOutputDevice(const BlackMisc::Voice::CAudioDevice &device) = 0;
|
||||
|
||||
/*!
|
||||
* \brief Input device to be used
|
||||
*/
|
||||
virtual void setInputDevice(const BlackMisc::Voice::CAudioDevice &device) = 0;
|
||||
|
||||
/*!
|
||||
* Get COM1/2 voice rooms, which then allows to retrieve information
|
||||
* such as audio status etc.
|
||||
@@ -177,6 +188,18 @@ namespace BlackCore
|
||||
*/
|
||||
virtual BlackMisc::Aviation::CCallsignList getVoiceRoomCallsigns(const ComUnit comUnit) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Is muted?
|
||||
*/
|
||||
virtual bool isMuted() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Switch audio output, enable or disable given COM unit.
|
||||
* \param comUnit
|
||||
* \param enable enable or disable output
|
||||
*/
|
||||
virtual void switchAudioOutput(const ComUnit comUnit, bool enable) = 0;
|
||||
|
||||
signals:
|
||||
// Signals regarding the voice server connection
|
||||
void notConnected(const ComUnit comUnit);
|
||||
|
||||
@@ -43,6 +43,8 @@ namespace BlackCore
|
||||
this->m_voiceRooms.push_back(CVoiceRoom()); // COM2
|
||||
this->m_outputEnabled.insert(COM1, true);
|
||||
this->m_outputEnabled.insert(COM2, true);
|
||||
this->m_currentInputDevice = this->defaultAudioInputDevice();
|
||||
this->m_currentOutputDevice = this->defaultAudioOutputDevice();
|
||||
|
||||
// do processing
|
||||
this->startTimer(100);
|
||||
@@ -87,6 +89,22 @@ namespace BlackCore
|
||||
return BlackMisc::Voice::CAudioDevice(BlackMisc::Voice::CAudioDevice::OutputDevice, BlackMisc::Voice::CAudioDevice::defaultDevice(), "default");
|
||||
}
|
||||
|
||||
/*
|
||||
* Current output device
|
||||
*/
|
||||
CAudioDevice CVoiceVatlib::getCurrentOutputDevice() const
|
||||
{
|
||||
return m_currentOutputDevice;
|
||||
}
|
||||
|
||||
/*
|
||||
* Current input device
|
||||
*/
|
||||
CAudioDevice CVoiceVatlib::getCurrentInputDevice() const
|
||||
{
|
||||
return m_currentInputDevice;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set input device
|
||||
*/
|
||||
@@ -109,6 +127,7 @@ namespace BlackCore
|
||||
{
|
||||
qWarning() << "Input device hit a fatal error";
|
||||
}
|
||||
this->m_currentInputDevice = device;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -135,6 +154,7 @@ namespace BlackCore
|
||||
{
|
||||
qWarning() << "Input device hit a fatal error";
|
||||
}
|
||||
this->m_currentOutputDevice = device;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
@@ -51,8 +51,6 @@ namespace BlackCore
|
||||
virtual const BlackMisc::Voice::CAudioDeviceList &audioDevices() const ;
|
||||
virtual const BlackMisc::Voice::CAudioDevice defaultAudioInputDevice() const;
|
||||
virtual const BlackMisc::Voice::CAudioDevice defaultAudioOutputDevice() const;
|
||||
virtual void setInputDevice(const BlackMisc::Voice::CAudioDevice &device);
|
||||
virtual void setOutputDevice(const BlackMisc::Voice::CAudioDevice &device);
|
||||
|
||||
/************************************************
|
||||
* SETUP TESTS
|
||||
@@ -121,9 +119,27 @@ namespace BlackCore
|
||||
virtual BlackMisc::Aviation::CCallsignList getVoiceRoomCallsigns(const ComUnit comUnit) const;
|
||||
|
||||
/*!
|
||||
* \brief Switch audio output, enable or disable given COM unit.
|
||||
* \param comUnit
|
||||
* \param enable enable or disable output
|
||||
* \copydoc IVoice::setInputDevice
|
||||
*/
|
||||
virtual void setInputDevice(const BlackMisc::Voice::CAudioDevice &device);
|
||||
|
||||
/*!
|
||||
* \copydoc IVoice::setOutputDevice
|
||||
*/
|
||||
virtual void setOutputDevice(const BlackMisc::Voice::CAudioDevice &device);
|
||||
|
||||
/*!
|
||||
* \brief Current input device
|
||||
*/
|
||||
virtual BlackMisc::Voice::CAudioDevice getCurrentInputDevice() const;
|
||||
|
||||
/*!
|
||||
* \brief Current output device
|
||||
*/
|
||||
virtual BlackMisc::Voice::CAudioDevice getCurrentOutputDevice() const;
|
||||
|
||||
/*!
|
||||
* \copydoc IVoice::switchAudioOutput
|
||||
*/
|
||||
virtual void switchAudioOutput(const ComUnit comUnit, bool enable);
|
||||
|
||||
@@ -281,6 +297,8 @@ namespace BlackCore
|
||||
BlackMisc::Aviation::CCallsign m_aircraftCallsign; /*!< own callsign to join voice rooms */
|
||||
BlackMisc::Voice::CVoiceRoomList m_voiceRooms;
|
||||
BlackMisc::Voice::CAudioDeviceList m_devices; /*!< in and output devices */
|
||||
BlackMisc::Voice::CAudioDevice m_currentOutputDevice;
|
||||
BlackMisc::Voice::CAudioDevice m_currentInputDevice;
|
||||
QScopedPointer<CKeyboard> m_keyboardPtt; /*!< handler for PTT */
|
||||
bool m_pushToTalk; /*!< flag, PTT pressed */
|
||||
float m_inputSquelch;
|
||||
|
||||
Reference in New Issue
Block a user