mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-24 06:25:37 +08:00
[AFV] Ref T730, check for same device
This commit is contained in:
@@ -59,6 +59,8 @@ namespace BlackCore
|
|||||||
connect(m_connection, &CClientConnection::audioReceived, this, &CAfvClient::audioOutDataAvailable);
|
connect(m_connection, &CClientConnection::audioReceived, this, &CAfvClient::audioOutDataAvailable);
|
||||||
connect(m_voiceServerPositionTimer, &QTimer::timeout, this, &CAfvClient::onPositionUpdateTimer);
|
connect(m_voiceServerPositionTimer, &QTimer::timeout, this, &CAfvClient::onPositionUpdateTimer);
|
||||||
|
|
||||||
|
m_updateTimer.stop(); // not used
|
||||||
|
|
||||||
// deferred init - use BlackMisc:: singleShot to call in correct thread, "myself" NOT needed
|
// deferred init - use BlackMisc:: singleShot to call in correct thread, "myself" NOT needed
|
||||||
BlackMisc::singleShot(1000, this, [ = ]
|
BlackMisc::singleShot(1000, this, [ = ]
|
||||||
{
|
{
|
||||||
@@ -264,7 +266,6 @@ namespace BlackCore
|
|||||||
m_connection->setReceiveAudio(false);
|
m_connection->setReceiveAudio(false);
|
||||||
|
|
||||||
// stop input/output
|
// stop input/output
|
||||||
m_updateTimer.stop();
|
|
||||||
m_input->stop();
|
m_input->stop();
|
||||||
m_output->stop();
|
m_output->stop();
|
||||||
CLogMessage(this).info(u"Client stopped");
|
CLogMessage(this).info(u"Client stopped");
|
||||||
@@ -910,6 +911,18 @@ namespace BlackCore
|
|||||||
return nullDevice;
|
return nullDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAfvClient::usesSameDevices(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice)
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&m_mutex);
|
||||||
|
if (!m_output || !m_input) { return false; }
|
||||||
|
const CAudioDeviceInfo i = m_input->device();
|
||||||
|
const CAudioDeviceInfo o = m_output->device();
|
||||||
|
lock.unlock();
|
||||||
|
|
||||||
|
return i.matchesNameTypeHostName(inputDevice) &&
|
||||||
|
o.matchesNameTypeHostName(outputDevice);
|
||||||
|
}
|
||||||
|
|
||||||
CAfvClient::ConnectionStatus CAfvClient::getConnectionStatus() const
|
CAfvClient::ConnectionStatus CAfvClient::getConnectionStatus() const
|
||||||
{
|
{
|
||||||
return m_connection->isConnected() ? Connected : Disconnected;
|
return m_connection->isConnected() ? Connected : Disconnected;
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ namespace BlackCore
|
|||||||
//! @{
|
//! @{
|
||||||
const BlackMisc::Audio::CAudioDeviceInfo &getInputDevice() const;
|
const BlackMisc::Audio::CAudioDeviceInfo &getInputDevice() const;
|
||||||
const BlackMisc::Audio::CAudioDeviceInfo &getOutputDevice() const;
|
const BlackMisc::Audio::CAudioDeviceInfo &getOutputDevice() const;
|
||||||
|
bool usesSameDevices(const BlackMisc::Audio::CAudioDeviceInfo &inputDevice, const BlackMisc::Audio::CAudioDeviceInfo &outputDevice);
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Callsigns currently received
|
//! Callsigns currently received
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackmisc/audio/audiodeviceinfo.h"
|
#include "blackmisc/audio/audiodeviceinfo.h"
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
|
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
@@ -26,6 +27,13 @@ namespace BlackMisc
|
|||||||
m_deviceName(name), m_hostName(QHostInfo::localHostName())
|
m_deviceName(name), m_hostName(QHostInfo::localHostName())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
bool CAudioDeviceInfo::matchesNameTypeHostName(const CAudioDeviceInfo &device) const
|
||||||
|
{
|
||||||
|
return device.getType() == this->getType() &&
|
||||||
|
stringCompare(device.getName(), this->getName(), Qt::CaseInsensitive) &&
|
||||||
|
stringCompare(device.getHostName(), this->getHostName(), Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
||||||
CAudioDeviceInfo::DeviceType CAudioDeviceInfo::fromQtMode(QAudio::Mode m)
|
CAudioDeviceInfo::DeviceType CAudioDeviceInfo::fromQtMode(QAudio::Mode m)
|
||||||
{
|
{
|
||||||
switch (m)
|
switch (m)
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ namespace BlackMisc
|
|||||||
//! Is this a default device?
|
//! Is this a default device?
|
||||||
bool isDefault() const { return m_deviceName == "default"; }
|
bool isDefault() const { return m_deviceName == "default"; }
|
||||||
|
|
||||||
|
//! Mathcing name, type and machine
|
||||||
|
bool matchesNameTypeHostName(const CAudioDeviceInfo &device) const;
|
||||||
|
|
||||||
//! Convert the Qt type
|
//! Convert the Qt type
|
||||||
static DeviceType fromQtMode(QAudio::Mode m);
|
static DeviceType fromQtMode(QAudio::Mode m);
|
||||||
|
|
||||||
|
|||||||
@@ -76,13 +76,11 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CAudioDeviceInfo CAudioDeviceInfoList::findRegisteredDevice(const CAudioDeviceInfo &device) const
|
CAudioDeviceInfo CAudioDeviceInfoList::findRegisteredDevice(const CAudioDeviceInfo &device) const
|
||||||
{
|
{
|
||||||
CAudioDeviceInfoList devices = device.isInputDevice() ? this->getInputDevices() : this->getOutputDevices();
|
for (const CAudioDeviceInfo &d : *this)
|
||||||
if (devices.isEmpty()) { return {}; }
|
{
|
||||||
|
if (device.matchesNameTypeHostName(d)) { return d; }
|
||||||
devices = devices.findByHostName(device.getHostName());
|
}
|
||||||
if (devices.isEmpty()) { return {}; }
|
return {};
|
||||||
|
|
||||||
return devices.findByName(device.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAudioDeviceInfoList::registerDevice(const CAudioDeviceInfo &device)
|
void CAudioDeviceInfoList::registerDevice(const CAudioDeviceInfo &device)
|
||||||
|
|||||||
Reference in New Issue
Block a user