diff --git a/src/blackcore/blackcore.contextvoice.xml b/src/blackcore/blackcore.contextvoice.xml
index 9b12ad748..4da1d563f 100644
--- a/src/blackcore/blackcore.contextvoice.xml
+++ b/src/blackcore/blackcore.contextvoice.xml
@@ -56,13 +56,17 @@
-
+
-
+
+
+
+
+
diff --git a/src/blackcore/blackcore.pro b/src/blackcore/blackcore.pro
index ca2a62be2..9bae03b18 100644
--- a/src/blackcore/blackcore.pro
+++ b/src/blackcore/blackcore.pro
@@ -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
diff --git a/src/blackcore/context_voice.cpp b/src/blackcore/context_voice.cpp
index 8f410cda5..99d197957 100644
--- a/src/blackcore/context_voice.cpp
+++ b/src/blackcore/context_voice.cpp
@@ -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
diff --git a/src/blackcore/context_voice.h b/src/blackcore/context_voice.h
index 2473f9f96..209aeb833 100644
--- a/src/blackcore/context_voice.h
+++ b/src/blackcore/context_voice.h
@@ -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
};
}
diff --git a/src/blackcore/context_voice_interface.cpp b/src/blackcore/context_voice_interface.cpp
index ccd5f0ab8..2df62c853 100644
--- a/src/blackcore/context_voice_interface.cpp
+++ b/src/blackcore/context_voice_interface.cpp
@@ -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(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);
}
/*
diff --git a/src/blackcore/context_voice_interface.h b/src/blackcore/context_voice_interface.h
index fdb337089..9bd64b8ab 100644
--- a/src/blackcore/context_voice_interface.h
+++ b/src/blackcore/context_voice_interface.h
@@ -187,6 +187,10 @@ namespace BlackCore
*/
virtual bool isMuted() const;
+ /*!
+ * \brief Play SELCAL tone
+ */
+ virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const;
};
}
diff --git a/src/blackcore/voice.h b/src/blackcore/voice.h
index fa3904e67..30e684387 100644
--- a/src/blackcore/voice.h
+++ b/src/blackcore/voice.h
@@ -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);
diff --git a/src/blackcore/voice_vatlib.cpp b/src/blackcore/voice_vatlib.cpp
index 7fd8f86a5..422f63a4d 100644
--- a/src/blackcore/voice_vatlib.cpp
+++ b/src/blackcore/voice_vatlib.cpp
@@ -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 (...)
{
diff --git a/src/blackcore/voice_vatlib.h b/src/blackcore/voice_vatlib.h
index 33cf122f4..06ad3efbd 100644
--- a/src/blackcore/voice_vatlib.h
+++ b/src/blackcore/voice_vatlib.h
@@ -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 m_keyboardPtt; /*!< handler for PTT */
bool m_pushToTalk; /*!< flag, PTT pressed */
float m_inputSquelch;