diff --git a/src/device.h b/src/device.h --- a/src/device.h +++ b/src/device.h @@ -43,6 +43,7 @@ Q_PROPERTY(QList ports READ ports NOTIFY portsChanged) Q_PROPERTY(quint32 activePortIndex READ activePortIndex WRITE setActivePortIndex NOTIFY activePortIndexChanged) Q_PROPERTY(bool default READ isDefault WRITE setDefault NOTIFY defaultChanged) + Q_PROPERTY(bool virtualDevice READ isVirtualDevice NOTIFY virtualDeviceChanged) public: enum State { InvalidState = 0, @@ -102,6 +103,12 @@ m_state = infoState; emit stateChanged(); } + + const bool isVirtual = !(info->flags & 4); // PA_X_HARDWARE + if (m_virtualDevice != isVirtual) { + m_virtualDevice = isVirtual; + emit virtualDeviceChanged(); + } } State state() const; @@ -114,6 +121,7 @@ virtual void setActivePortIndex(quint32 port_index) = 0; virtual bool isDefault() const = 0; virtual void setDefault(bool enable) = 0; + bool isVirtualDevice() const; signals: void stateChanged(); @@ -124,6 +132,7 @@ void portsChanged(); void activePortIndexChanged(); void defaultChanged(); + void virtualDeviceChanged(); protected: Device(QObject *parent); @@ -138,6 +147,7 @@ QList m_ports; quint32 m_activePortIndex = -1; State m_state = UnknownState; + bool m_virtualDevice = false; }; } // QPulseAudio diff --git a/src/device.cpp b/src/device.cpp --- a/src/device.cpp +++ b/src/device.cpp @@ -55,6 +55,11 @@ return m_activePortIndex; } +bool QPulseAudio::Device::isVirtualDevice() const +{ + return m_virtualDevice; +} + QPulseAudio::Device::Device(QObject *parent) : VolumeObject(parent) { diff --git a/src/pulseaudio.cpp b/src/pulseaudio.cpp --- a/src/pulseaudio.cpp +++ b/src/pulseaudio.cpp @@ -297,7 +297,7 @@ QMapIterator it(context()->sinks().data()); while (it.hasNext()) { it.next(); - if (it.value()->state() != state) { + if (it.value()->isVirtualDevice() || it.value()->state() != state) { continue; } if (!ret) {