8#include <QMediaDevices>
17namespace swift::misc::audio
22 : m_type(static_cast<int>(type)), m_deviceName(name)
27 if (m_deviceName.isEmpty())
31 if (m_deviceName ==
"default")
35 if (this->
isInputDevice() && m_deviceName == QMediaDevices::defaultAudioInput().description())
39 if (this->
isOutputDevice() && m_deviceName == QMediaDevices::defaultAudioOutput().description())
63 if (QMediaDevices::defaultAudioOutput().isNull())
return { Unknown,
"" };
64 return { OutputDevice, QMediaDevices::defaultAudioOutput().description() };
69 if (QMediaDevices::defaultAudioInput().isNull())
return { Unknown,
"" };
70 return { InputDevice, QMediaDevices::defaultAudioInput().description() };
84 case IndexIdentifier:
return m_identifier.propertyByIndex(index.
copyFrontRemoved());
99 case IndexDeviceType: m_type =
static_cast<DeviceType>(variant.
toInt());
return;
100 case IndexName: m_deviceName = variant.
toString();
return;
101 case IndexIdentifier: m_identifier.setPropertyByIndex(index.
copyFrontRemoved(), variant);
return;
115 case IndexDeviceTypeAsString:
117 case IndexName:
return m_deviceName.compare(compareValue.m_deviceName,
Qt::CaseInsensitive);
118 case IndexIdentifier:
128 static const QString i(
"input");
129 static const QString o(
"output");
130 static const QString u(
"unknown");
134 case InputDevice:
return i;
135 case OutputDevice:
return o;
144 if (!m_identifier.hasName())
qint64 getProcessId() const
Get process id.
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
QString toQString(bool i18n=false) const
Cast as QString.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
bool matchesNameTypeMachineProcess(const CAudioDeviceInfo &device) const
Matching name, type and machine and process.
static CAudioDeviceInfo getDefaultInputDevice()
Default input device.
bool isInputDevice() const
Input device.
int comparePropertyByIndex(CPropertyIndexRef index, const CAudioDeviceInfo &compareValue) const
Compare for index.
const QString & getMachineName() const
Machine name.
const QString & getTypeAsString() const
Type as string.
ColumnIndex
Properties by index.
bool isDefault() const
Is this a default device?
const QString & getName() const
Get the device name.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
DeviceType getType() const
Type.
bool isOutputDevice() const
Output device.
static CAudioDeviceInfo getDefaultOutputDevice()
Default output device.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
CAudioDeviceInfo()
Default constructor.
const CIdentifier & getIdentifier() const
Identifier.
bool matchesNameTypeMachineName(const CAudioDeviceInfo &device) const
Matching name, type and machine.
static const QString & deviceTypeToString(DeviceType t)
Device type as string.
QString convertToQString(bool i18n=false) const
Cast as QString.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
int compare(T a, T b)
Compare arithmetic values.
SWIFT_MISC_EXPORT bool stringCompare(const QString &c1, const QString &c2, Qt::CaseSensitivity cs)
String compare.
QVariant fromValue(T &&value)
int toInt(bool *ok) const const
QString toString() const const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.