mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
[AFV] Remove obsolete VVL device index from CAudioDeviceInfo
This commit is contained in:
committed by
Mat Sutcliffe
parent
33d125c121
commit
c759d45bb0
@@ -17,12 +17,12 @@ namespace BlackMisc
|
|||||||
namespace Audio
|
namespace Audio
|
||||||
{
|
{
|
||||||
CAudioDeviceInfo::CAudioDeviceInfo() :
|
CAudioDeviceInfo::CAudioDeviceInfo() :
|
||||||
m_type(Unknown), m_deviceIndex(invalidDeviceIndex()),
|
m_type(Unknown),
|
||||||
m_hostName(QHostInfo::localHostName())
|
m_hostName(QHostInfo::localHostName())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const int index, const QString &name) :
|
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const QString &name) :
|
||||||
m_type(type), m_deviceIndex(index),
|
m_type(type),
|
||||||
m_deviceName(name), m_hostName(QHostInfo::localHostName())
|
m_deviceName(name), m_hostName(QHostInfo::localHostName())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|||||||
@@ -41,14 +41,10 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//!
|
//!
|
||||||
//! Default constructor.
|
//! Default constructor.
|
||||||
//! \note If m_deviceIndex is -1, default should be used. However on Windows this doesnt work. Needs to be checked in Vatlib.
|
|
||||||
CAudioDeviceInfo();
|
CAudioDeviceInfo();
|
||||||
|
|
||||||
//! Constructor.
|
//! Constructor.
|
||||||
CAudioDeviceInfo(DeviceType type, const int index, const QString &getName);
|
CAudioDeviceInfo(DeviceType type, const QString &getName);
|
||||||
|
|
||||||
//! Get the device index
|
|
||||||
int getIndex() const { return m_deviceIndex; }
|
|
||||||
|
|
||||||
//! Get the device name
|
//! Get the device name
|
||||||
const QString &getName() const { return m_deviceName; }
|
const QString &getName() const { return m_deviceName; }
|
||||||
@@ -60,7 +56,7 @@ namespace BlackMisc
|
|||||||
DeviceType getType() const { return m_type; }
|
DeviceType getType() const { return m_type; }
|
||||||
|
|
||||||
//! Valid audio device object?
|
//! Valid audio device object?
|
||||||
bool isValid() const { return m_deviceIndex != Unknown && !m_deviceName.isEmpty(); }
|
bool isValid() const { return !m_deviceName.isEmpty(); }
|
||||||
|
|
||||||
//! To QAudioDeviceInfo
|
//! To QAudioDeviceInfo
|
||||||
QAudioDeviceInfo toAudioDeviceInfo() const;
|
QAudioDeviceInfo toAudioDeviceInfo() const;
|
||||||
@@ -68,22 +64,16 @@ namespace BlackMisc
|
|||||||
//! Convert the Qt type
|
//! Convert the Qt type
|
||||||
static DeviceType fromQtMode(QAudio::Mode m);
|
static DeviceType fromQtMode(QAudio::Mode m);
|
||||||
|
|
||||||
//! Device index for default device
|
|
||||||
static int defaultDeviceIndex() {return -1;}
|
|
||||||
|
|
||||||
//! Invalid device index
|
|
||||||
static int invalidDeviceIndex() {return -2;}
|
|
||||||
|
|
||||||
//! Default output device
|
//! Default output device
|
||||||
static CAudioDeviceInfo getDefaultOutputDevice()
|
static CAudioDeviceInfo getDefaultOutputDevice()
|
||||||
{
|
{
|
||||||
return CAudioDeviceInfo(OutputDevice, defaultDeviceIndex(), "default");
|
return CAudioDeviceInfo(OutputDevice, "default");
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Default input device
|
//! Default input device
|
||||||
static CAudioDeviceInfo getDefaultInputDevice()
|
static CAudioDeviceInfo getDefaultInputDevice()
|
||||||
{
|
{
|
||||||
return CAudioDeviceInfo(InputDevice, defaultDeviceIndex(), "default");
|
return CAudioDeviceInfo(InputDevice, "default");
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
@@ -91,14 +81,12 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DeviceType m_type = Unknown; //!< Device type, @see CAudioDeviceInfo::DeviceType
|
DeviceType m_type = Unknown; //!< Device type, @see CAudioDeviceInfo::DeviceType
|
||||||
int m_deviceIndex = -1; //!< deviceIndex is the number is the reference for the VVL. The device is selected by this index. The managing class needs to take care, that indexes are valid.
|
|
||||||
QString m_deviceName; //!< Device name
|
QString m_deviceName; //!< Device name
|
||||||
QString m_hostName; //!< We use a DBus based system. Hence an audio device can reside on a differen computers, this here is its name
|
QString m_hostName; //!< We use a DBus based system. Hence an audio device can reside on a differen computers, this here is its name
|
||||||
|
|
||||||
BLACK_METACLASS(
|
BLACK_METACLASS(
|
||||||
CAudioDeviceInfo,
|
CAudioDeviceInfo,
|
||||||
BLACK_METAMEMBER(type),
|
BLACK_METAMEMBER(type),
|
||||||
BLACK_METAMEMBER(deviceIndex),
|
|
||||||
BLACK_METAMEMBER(deviceName),
|
BLACK_METAMEMBER(deviceName),
|
||||||
BLACK_METAMEMBER(hostName)
|
BLACK_METAMEMBER(hostName)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -53,11 +53,6 @@ namespace BlackMisc
|
|||||||
return CAudioDeviceInfo();
|
return CAudioDeviceInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
CAudioDeviceInfo CAudioDeviceInfoList::findByDeviceIndex(int deviceIndex)
|
|
||||||
{
|
|
||||||
return this->findBy(&CAudioDeviceInfo::getIndex, deviceIndex).frontOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
int CAudioDeviceInfoList::count(CAudioDeviceInfo::DeviceType type) const
|
int CAudioDeviceInfoList::count(CAudioDeviceInfo::DeviceType type) const
|
||||||
{
|
{
|
||||||
return static_cast<int>(std::count_if(this->begin(), this->end(), [type](const CAudioDeviceInfo & device)
|
return static_cast<int>(std::count_if(this->begin(), this->end(), [type](const CAudioDeviceInfo & device)
|
||||||
@@ -81,10 +76,9 @@ namespace BlackMisc
|
|||||||
const QList<QAudioDeviceInfo> inputDevices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
const QList<QAudioDeviceInfo> inputDevices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
||||||
CAudioDeviceInfoList devices;
|
CAudioDeviceInfoList devices;
|
||||||
|
|
||||||
int index = 100;
|
|
||||||
for (const QAudioDeviceInfo &inputDevice : inputDevices)
|
for (const QAudioDeviceInfo &inputDevice : inputDevices)
|
||||||
{
|
{
|
||||||
const CAudioDeviceInfo d(CAudioDeviceInfo::InputDevice, index++, inputDevice.deviceName());
|
const CAudioDeviceInfo d(CAudioDeviceInfo::InputDevice, inputDevice.deviceName());
|
||||||
devices.push_back(d);
|
devices.push_back(d);
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
@@ -95,10 +89,9 @@ namespace BlackMisc
|
|||||||
const QList<QAudioDeviceInfo> outputDevices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
const QList<QAudioDeviceInfo> outputDevices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||||
CAudioDeviceInfoList devices;
|
CAudioDeviceInfoList devices;
|
||||||
|
|
||||||
int index = 200;
|
|
||||||
for (const QAudioDeviceInfo &outputDevice : outputDevices)
|
for (const QAudioDeviceInfo &outputDevice : outputDevices)
|
||||||
{
|
{
|
||||||
const CAudioDeviceInfo d(CAudioDeviceInfo::OutputDevice, index++, outputDevice.deviceName());
|
const CAudioDeviceInfo d(CAudioDeviceInfo::OutputDevice, outputDevice.deviceName());
|
||||||
devices.push_back(d);
|
devices.push_back(d);
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
|
|||||||
@@ -48,9 +48,6 @@ namespace BlackMisc
|
|||||||
//! Find by name
|
//! Find by name
|
||||||
CAudioDeviceInfo findByName(const QString &name, bool strict = false) const;
|
CAudioDeviceInfo findByName(const QString &name, bool strict = false) const;
|
||||||
|
|
||||||
//! Find device by its index
|
|
||||||
CAudioDeviceInfo findByDeviceIndex(int deviceIndex);
|
|
||||||
|
|
||||||
//! Count (as of type)
|
//! Count (as of type)
|
||||||
int count(CAudioDeviceInfo::DeviceType type) const;
|
int count(CAudioDeviceInfo::DeviceType type) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user