mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
[AFV] Ref T730, check for same device
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/audio/audiodeviceinfo.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
|
||||
#include <QStringBuilder>
|
||||
#include <QHostInfo>
|
||||
@@ -26,6 +27,13 @@ namespace BlackMisc
|
||||
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)
|
||||
{
|
||||
switch (m)
|
||||
|
||||
@@ -67,6 +67,9 @@ namespace BlackMisc
|
||||
//! Is this a default device?
|
||||
bool isDefault() const { return m_deviceName == "default"; }
|
||||
|
||||
//! Mathcing name, type and machine
|
||||
bool matchesNameTypeHostName(const CAudioDeviceInfo &device) const;
|
||||
|
||||
//! Convert the Qt type
|
||||
static DeviceType fromQtMode(QAudio::Mode m);
|
||||
|
||||
|
||||
@@ -76,13 +76,11 @@ namespace BlackMisc
|
||||
|
||||
CAudioDeviceInfo CAudioDeviceInfoList::findRegisteredDevice(const CAudioDeviceInfo &device) const
|
||||
{
|
||||
CAudioDeviceInfoList devices = device.isInputDevice() ? this->getInputDevices() : this->getOutputDevices();
|
||||
if (devices.isEmpty()) { return {}; }
|
||||
|
||||
devices = devices.findByHostName(device.getHostName());
|
||||
if (devices.isEmpty()) { return {}; }
|
||||
|
||||
return devices.findByName(device.getName());
|
||||
for (const CAudioDeviceInfo &d : *this)
|
||||
{
|
||||
if (device.matchesNameTypeHostName(d)) { return d; }
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void CAudioDeviceInfoList::registerDevice(const CAudioDeviceInfo &device)
|
||||
|
||||
Reference in New Issue
Block a user