mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 17:30:12 +08:00
refs #320 Prepare Voice to new vatlib API
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
#include "context_settings.h"
|
#include "context_settings.h"
|
||||||
#include "context_runtime.h"
|
#include "context_runtime.h"
|
||||||
#include "dbus_server.h"
|
#include "dbus_server.h"
|
||||||
#include "voice_vatlib.h"
|
#include "voice.h"
|
||||||
#include "voice_channel.h"
|
#include "voice_channel.h"
|
||||||
#include "input_manager.h"
|
#include "input_manager.h"
|
||||||
#include "blackinput/keyboard.h"
|
#include "blackinput/keyboard.h"
|
||||||
@@ -163,8 +163,7 @@ namespace BlackCore
|
|||||||
//! Connection in transition
|
//! Connection in transition
|
||||||
bool inTransitionState() const;
|
bool inTransitionState() const;
|
||||||
|
|
||||||
// TODO: see #339, MS' comment on deletion in another thread
|
std::unique_ptr<CVoiceVatlib> m_voice; //!< underlying voice lib
|
||||||
QScopedPointer<CVoiceVatlib> m_voice; //!< underlying voice lib
|
|
||||||
|
|
||||||
CInputManager *m_inputManager = nullptr;
|
CInputManager *m_inputManager = nullptr;
|
||||||
CInputManager::RegistrationHandle m_handlePtt;
|
CInputManager::RegistrationHandle m_handlePtt;
|
||||||
|
|||||||
@@ -13,35 +13,20 @@
|
|||||||
#include "../blackmisc/audiodeviceinfolist.h"
|
#include "../blackmisc/audiodeviceinfolist.h"
|
||||||
#include "../blackmisc/statusmessage.h"
|
#include "../blackmisc/statusmessage.h"
|
||||||
|
|
||||||
#include <vatlib/vatlib.h>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSet>
|
|
||||||
#include <QStringList>
|
#include <memory>
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
class IVoiceChannel;
|
class IVoiceChannel;
|
||||||
|
|
||||||
/*!
|
//! Interface to a connection to a ATC voice server for use in flight simulation.
|
||||||
* Interface to a connection to a ATC voice server for use in flight simulation.
|
|
||||||
*
|
|
||||||
* \warning If an INetwork signal is connected to a slot, and that slot emits a signal
|
|
||||||
* which is connected to an INetwork slot, then at least one of those connections
|
|
||||||
* must be a Qt::QueuedConnection.
|
|
||||||
* Reason: IVoiceClient implementations are not re-entrant.
|
|
||||||
*/
|
|
||||||
class IVoice : public QObject
|
class IVoice : public QObject
|
||||||
{
|
{
|
||||||
|
|
||||||
/* TODOS:
|
|
||||||
* - Find a replacement for comUnit. Maybe map it to the ComUnit in the aircraft as a class
|
|
||||||
* - Settings: Settings classes to store hardware settings (squelch, background noise, hardware device)
|
|
||||||
*/
|
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Default constructor with parent
|
* \brief Default constructor with parent
|
||||||
@@ -49,7 +34,6 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
IVoice(QObject *parent = nullptr);
|
IVoice(QObject *parent = nullptr);
|
||||||
|
|
||||||
public:
|
|
||||||
//! Virtual destructor.
|
//! Virtual destructor.
|
||||||
virtual ~IVoice() {}
|
virtual ~IVoice() {}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
@@ -21,10 +21,17 @@ namespace BlackCore
|
|||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
CVoiceVatlib::CVoiceVatlib(QObject *parent) :
|
CVoiceVatlib::CVoiceVatlib(QObject *parent) :
|
||||||
IVoice(parent)
|
IVoice(parent),
|
||||||
|
m_audioService(Vat_CreateAudioService()),
|
||||||
|
m_udpPort(Vat_CreateUDPAudioPort(m_audioService.data(), 3782))
|
||||||
{
|
{
|
||||||
|
Vat_SetVoiceErrorHandler(CVoiceVatlib::voiceErrorHandler);
|
||||||
|
|
||||||
this->m_currentInputDevice = this->defaultAudioInputDevice();
|
this->m_currentInputDevice = this->defaultAudioInputDevice();
|
||||||
this->m_currentOutputDevice = this->defaultAudioOutputDevice();
|
this->m_currentOutputDevice = this->defaultAudioOutputDevice();
|
||||||
|
|
||||||
|
// do processing
|
||||||
|
this->startTimer(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -125,6 +132,8 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
void CVoiceVatlib::timerEvent(QTimerEvent *)
|
void CVoiceVatlib::timerEvent(QTimerEvent *)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT_X(m_audioService, "CVoiceVatlib", "VatAudioService invalid!");
|
||||||
|
Vat_ExecuteTasks(m_audioService.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -154,4 +163,9 @@ namespace BlackCore
|
|||||||
(*iterator)->updateRoomStatus(roomStatus);
|
(*iterator)->updateRoomStatus(roomStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CVoiceVatlib::voiceErrorHandler(const char *message)
|
||||||
|
{
|
||||||
|
CLogMessage(static_cast<CVoiceVatlib*>(nullptr)).error(message);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
#define BLACKCORE_VOICE_VATLIB_H
|
#define BLACKCORE_VOICE_VATLIB_H
|
||||||
|
|
||||||
#include "voice.h"
|
#include "voice.h"
|
||||||
|
#include <vatlib/vatlib2.h>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#ifndef NOMINMAX
|
#ifndef NOMINMAX
|
||||||
@@ -86,11 +88,32 @@ namespace BlackCore
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// this struct calls "myCustomDeallocator" to delete the pointer
|
||||||
|
struct VatAudioServiceDeleter
|
||||||
|
{
|
||||||
|
static inline void cleanup(VatAudioService_tag *obj)
|
||||||
|
{
|
||||||
|
Vat_DestroyAudioService(obj);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VatUDPAudioPortDeleter
|
||||||
|
{
|
||||||
|
static inline void cleanup(VatUDPAudioPort_tag *obj)
|
||||||
|
{
|
||||||
|
Vat_DestroyUDPAudioPort(obj);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void voiceErrorHandler(const char *message);
|
||||||
|
|
||||||
// shimlib callbacks
|
// shimlib callbacks
|
||||||
static void onRoomStatusUpdate(Cvatlib_Voice_Simple *obj, Cvatlib_Voice_Simple::roomStatusUpdate upd, qint32 roomIndex, void *cbVar);
|
static void onRoomStatusUpdate(Cvatlib_Voice_Simple *obj, Cvatlib_Voice_Simple::roomStatusUpdate upd, qint32 roomIndex, void *cbVar);
|
||||||
|
|
||||||
void onRoomStatusUpdate(qint32 roomIndex, Cvatlib_Voice_Simple::roomStatusUpdate roomStatus);
|
void onRoomStatusUpdate(qint32 roomIndex, Cvatlib_Voice_Simple::roomStatusUpdate roomStatus);
|
||||||
|
|
||||||
|
QScopedPointer<VatAudioService_tag, VatAudioServiceDeleter> m_audioService;
|
||||||
|
QScopedPointer<VatUDPAudioPort_tag, VatUDPAudioPortDeleter> m_udpPort;
|
||||||
BlackMisc::Audio::CAudioDeviceInfoList m_devices; /*!< in and output devices */
|
BlackMisc::Audio::CAudioDeviceInfoList m_devices; /*!< in and output devices */
|
||||||
BlackMisc::Audio::CAudioDeviceInfo m_currentOutputDevice;
|
BlackMisc::Audio::CAudioDeviceInfo m_currentOutputDevice;
|
||||||
BlackMisc::Audio::CAudioDeviceInfo m_currentInputDevice;
|
BlackMisc::Audio::CAudioDeviceInfo m_currentInputDevice;
|
||||||
|
|||||||
Reference in New Issue
Block a user