mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +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
|
||||
{
|
||||
CAudioDeviceInfo::CAudioDeviceInfo() :
|
||||
m_type(Unknown), m_deviceIndex(invalidDeviceIndex()),
|
||||
m_type(Unknown),
|
||||
m_hostName(QHostInfo::localHostName())
|
||||
{ }
|
||||
|
||||
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const int index, const QString &name) :
|
||||
m_type(type), m_deviceIndex(index),
|
||||
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const QString &name) :
|
||||
m_type(type),
|
||||
m_deviceName(name), m_hostName(QHostInfo::localHostName())
|
||||
{ }
|
||||
|
||||
|
||||
@@ -41,14 +41,10 @@ namespace BlackMisc
|
||||
|
||||
//!
|
||||
//! 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();
|
||||
|
||||
//! Constructor.
|
||||
CAudioDeviceInfo(DeviceType type, const int index, const QString &getName);
|
||||
|
||||
//! Get the device index
|
||||
int getIndex() const { return m_deviceIndex; }
|
||||
CAudioDeviceInfo(DeviceType type, const QString &getName);
|
||||
|
||||
//! Get the device name
|
||||
const QString &getName() const { return m_deviceName; }
|
||||
@@ -60,7 +56,7 @@ namespace BlackMisc
|
||||
DeviceType getType() const { return m_type; }
|
||||
|
||||
//! Valid audio device object?
|
||||
bool isValid() const { return m_deviceIndex != Unknown && !m_deviceName.isEmpty(); }
|
||||
bool isValid() const { return !m_deviceName.isEmpty(); }
|
||||
|
||||
//! To QAudioDeviceInfo
|
||||
QAudioDeviceInfo toAudioDeviceInfo() const;
|
||||
@@ -68,22 +64,16 @@ namespace BlackMisc
|
||||
//! Convert the Qt type
|
||||
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
|
||||
static CAudioDeviceInfo getDefaultOutputDevice()
|
||||
{
|
||||
return CAudioDeviceInfo(OutputDevice, defaultDeviceIndex(), "default");
|
||||
return CAudioDeviceInfo(OutputDevice, "default");
|
||||
}
|
||||
|
||||
//! Default input device
|
||||
static CAudioDeviceInfo getDefaultInputDevice()
|
||||
{
|
||||
return CAudioDeviceInfo(InputDevice, defaultDeviceIndex(), "default");
|
||||
return CAudioDeviceInfo(InputDevice, "default");
|
||||
}
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
@@ -91,14 +81,12 @@ namespace BlackMisc
|
||||
|
||||
private:
|
||||
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_hostName; //!< We use a DBus based system. Hence an audio device can reside on a differen computers, this here is its name
|
||||
|
||||
BLACK_METACLASS(
|
||||
CAudioDeviceInfo,
|
||||
BLACK_METAMEMBER(type),
|
||||
BLACK_METAMEMBER(deviceIndex),
|
||||
BLACK_METAMEMBER(deviceName),
|
||||
BLACK_METAMEMBER(hostName)
|
||||
);
|
||||
|
||||
@@ -53,11 +53,6 @@ namespace BlackMisc
|
||||
return CAudioDeviceInfo();
|
||||
}
|
||||
|
||||
CAudioDeviceInfo CAudioDeviceInfoList::findByDeviceIndex(int deviceIndex)
|
||||
{
|
||||
return this->findBy(&CAudioDeviceInfo::getIndex, deviceIndex).frontOrDefault();
|
||||
}
|
||||
|
||||
int CAudioDeviceInfoList::count(CAudioDeviceInfo::DeviceType type) const
|
||||
{
|
||||
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);
|
||||
CAudioDeviceInfoList devices;
|
||||
|
||||
int index = 100;
|
||||
for (const QAudioDeviceInfo &inputDevice : inputDevices)
|
||||
{
|
||||
const CAudioDeviceInfo d(CAudioDeviceInfo::InputDevice, index++, inputDevice.deviceName());
|
||||
const CAudioDeviceInfo d(CAudioDeviceInfo::InputDevice, inputDevice.deviceName());
|
||||
devices.push_back(d);
|
||||
}
|
||||
return devices;
|
||||
@@ -95,10 +89,9 @@ namespace BlackMisc
|
||||
const QList<QAudioDeviceInfo> outputDevices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
CAudioDeviceInfoList devices;
|
||||
|
||||
int index = 200;
|
||||
for (const QAudioDeviceInfo &outputDevice : outputDevices)
|
||||
{
|
||||
const CAudioDeviceInfo d(CAudioDeviceInfo::OutputDevice, index++, outputDevice.deviceName());
|
||||
const CAudioDeviceInfo d(CAudioDeviceInfo::OutputDevice, outputDevice.deviceName());
|
||||
devices.push_back(d);
|
||||
}
|
||||
return devices;
|
||||
|
||||
@@ -48,9 +48,6 @@ namespace BlackMisc
|
||||
//! Find by name
|
||||
CAudioDeviceInfo findByName(const QString &name, bool strict = false) const;
|
||||
|
||||
//! Find device by its index
|
||||
CAudioDeviceInfo findByDeviceIndex(int deviceIndex);
|
||||
|
||||
//! Count (as of type)
|
||||
int count(CAudioDeviceInfo::DeviceType type) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user