6 #include <QAudioDevice>
8 #include <QMediaDevices>
17 namespace swift::misc::audio
22 : m_type(static_cast<int>(type)), m_deviceName(name)
27 if (m_deviceName.isEmpty()) {
return false; }
28 if (m_deviceName ==
"default") {
return true; }
29 if (this->
isInputDevice() && m_deviceName == QMediaDevices::defaultAudioInput().description()) {
return true; }
30 if (this->
isOutputDevice() && m_deviceName == QMediaDevices::defaultAudioOutput().description())
54 return { OutputDevice, QMediaDevices::defaultAudioOutput().description() };
59 return { InputDevice, QMediaDevices::defaultAudioInput().description() };
64 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
67 case IndexDeviceType:
return QVariant::fromValue(this->
getType());
68 case IndexDeviceTypeAsString:
return QVariant::fromValue(this->
getTypeAsString());
69 case IndexName:
return QVariant::fromValue(this->
getName());
85 case IndexDeviceType: m_type =
static_cast<DeviceType>(variant.toInt());
return;
86 case IndexName: m_deviceName = variant.toString();
return;
95 if (index.
isMyself()) {
return m_deviceName.compare(compareValue.m_deviceName, Qt::CaseInsensitive); }
98 case IndexDeviceTypeAsString:
99 case IndexDeviceType:
return Compare::compare(m_type, compareValue.m_type);
100 case IndexName:
return m_deviceName.compare(compareValue.m_deviceName, Qt::CaseInsensitive);
101 case IndexIdentifier:
111 static const QString i(
"input");
112 static const QString o(
"output");
113 static const QString u(
"unknown");
117 case InputDevice:
return i;
118 case OutputDevice:
return o;
127 if (!m_identifier.
hasName()) {
return m_deviceName; }
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
qint64 getProcessId() const
Get process id.
bool hasName() const
Has name.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const CIdentifier &compareValue) const
Compare for index.
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.
Value object encapsulating information of a audio device.
bool matchesNameTypeMachineProcess(const CAudioDeviceInfo &device) const
Matching name, type and machine and process.
const QString & getMachineName() const
Machine name.
static CAudioDeviceInfo getDefaultInputDevice()
Default input device.
bool isInputDevice() const
Input device.
int comparePropertyByIndex(CPropertyIndexRef index, const CAudioDeviceInfo &compareValue) const
Compare for index.
const CIdentifier & getIdentifier() const
Identifier.
ColumnIndex
Properties by index.
bool isDefault() const
Is this a default device?
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
DeviceType getType() const
Type.
const QString & getTypeAsString() const
Type as string.
bool isOutputDevice() const
Output device.
static CAudioDeviceInfo getDefaultOutputDevice()
Default output device.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
CAudioDeviceInfo()
Default constructor.
bool matchesNameTypeMachineName(const CAudioDeviceInfo &device) const
Matching name, type and machine.
const QString & getName() const
Get the device name.
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.
SWIFT_MISC_EXPORT bool stringCompare(const QString &c1, const QString &c2, Qt::CaseSensitivity cs)
String compare.
#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.