Skip to content

Commit eecc2f8

Browse files
committed
services/pipewire: ignore monitors in PwNodeLinkTracker
1 parent 11d6d67 commit eecc2f8

5 files changed

Lines changed: 14 additions & 3 deletions

File tree

changelog/next.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ set shell id.
2525

2626
- FreeBSD is now partially supported.
2727
- IPC operations filter available instances to the current display connection by default.
28+
- PwNodeLinkTracker ignores sound level monitoring programs.
2829

2930
## Bug Fixes
3031

src/services/pipewire/node.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ void PwNode::initProps(const spa_dict* props) {
164164
this->nick = nodeNick;
165165
}
166166

167+
if (const auto* nodeCategory = spa_dict_lookup(props, PW_KEY_MEDIA_CATEGORY)) {
168+
if (strcmp(nodeCategory, "Monitor") == 0 || strcmp(nodeCategory, "Manager") == 0) {
169+
this->isMonitor = true;
170+
}
171+
}
172+
167173
if (const auto* serial = spa_dict_lookup(props, PW_KEY_OBJECT_SERIAL)) {
168174
auto ok = false;
169175
auto value = QString::fromUtf8(serial).toULongLong(&ok);

src/services/pipewire/node.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ class PwNode: public PwBindable<pw_node, PW_TYPE_INTERFACE_Node, PW_VERSION_NODE
236236
QString nick;
237237
QMap<QString, QString> properties;
238238
quint64 objectSerial = 0;
239+
bool isMonitor = false;
239240

240241
PwNodeType::Flags type = PwNodeType::Untracked;
241242

src/services/pipewire/qml.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ void PwNodeLinkTracker::updateLinks() {
213213
|| (this->mNode->isSink() && link->inputNode() == this->mNode->id()))
214214
{
215215
auto* iface = PwLinkGroupIface::instance(link);
216+
if (iface->target()->node()->isMonitor) return;
216217

217218
// do not connect twice
218219
if (!this->mLinkGroups.contains(iface)) {
@@ -231,7 +232,7 @@ void PwNodeLinkTracker::updateLinks() {
231232

232233
for (auto* iface: this->mLinkGroups) {
233234
// only disconnect no longer used nodes
234-
if (!newLinks.contains(iface)) {
235+
if (!newLinks.contains(iface) || iface->target()->node()->isMonitor) {
235236
QObject::disconnect(iface, nullptr, this, nullptr);
236237
}
237238
}
@@ -271,6 +272,8 @@ void PwNodeLinkTracker::onLinkGroupCreated(PwLinkGroup* linkGroup) {
271272
|| (this->mNode->isSink() && linkGroup->inputNode() == this->mNode->id()))
272273
{
273274
auto* iface = PwLinkGroupIface::instance(linkGroup);
275+
if (iface->target()->node()->isMonitor) return;
276+
274277
QObject::connect(iface, &QObject::destroyed, this, &PwNodeLinkTracker::onLinkGroupDestroyed);
275278
this->mLinkGroups.push_back(iface);
276279
emit this->linkGroupsChanged();

src/services/pipewire/qml.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ private slots:
171171
ObjectModel<PwLinkGroupIface> mLinkGroups {this};
172172
};
173173

174-
///! Tracks all link connections to a given node.
174+
///! Tracks non-monitor link connections to a given node.
175175
class PwNodeLinkTracker: public QObject {
176176
Q_OBJECT;
177177
// clang-format off
178178
/// The node to track connections to.
179179
Q_PROPERTY(qs::service::pipewire::PwNodeIface* node READ node WRITE setNode NOTIFY nodeChanged);
180-
/// Link groups connected to the given node.
180+
/// Link groups connected to the given node, excluding monitors.
181181
///
182182
/// If the node is a sink, links which target the node will be tracked.
183183
/// If the node is a source, links which source the node will be tracked.

0 commit comments

Comments
 (0)