services/pipewire: ignore monitors in PwNodeLinkTracker

This commit is contained in:
outfoxxed 2026-01-09 00:58:30 -08:00
parent 11d6d67961
commit eecc2f88b3
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
5 changed files with 14 additions and 3 deletions

View file

@ -25,6 +25,7 @@ set shell id.
- FreeBSD is now partially supported.
- IPC operations filter available instances to the current display connection by default.
- PwNodeLinkTracker ignores sound level monitoring programs.
## Bug Fixes

View file

@ -164,6 +164,12 @@ void PwNode::initProps(const spa_dict* props) {
this->nick = nodeNick;
}
if (const auto* nodeCategory = spa_dict_lookup(props, PW_KEY_MEDIA_CATEGORY)) {
if (strcmp(nodeCategory, "Monitor") == 0 || strcmp(nodeCategory, "Manager") == 0) {
this->isMonitor = true;
}
}
if (const auto* serial = spa_dict_lookup(props, PW_KEY_OBJECT_SERIAL)) {
auto ok = false;
auto value = QString::fromUtf8(serial).toULongLong(&ok);

View file

@ -236,6 +236,7 @@ public:
QString nick;
QMap<QString, QString> properties;
quint64 objectSerial = 0;
bool isMonitor = false;
PwNodeType::Flags type = PwNodeType::Untracked;

View file

@ -213,6 +213,7 @@ void PwNodeLinkTracker::updateLinks() {
|| (this->mNode->isSink() && link->inputNode() == this->mNode->id()))
{
auto* iface = PwLinkGroupIface::instance(link);
if (iface->target()->node()->isMonitor) return;
// do not connect twice
if (!this->mLinkGroups.contains(iface)) {
@ -231,7 +232,7 @@ void PwNodeLinkTracker::updateLinks() {
for (auto* iface: this->mLinkGroups) {
// only disconnect no longer used nodes
if (!newLinks.contains(iface)) {
if (!newLinks.contains(iface) || iface->target()->node()->isMonitor) {
QObject::disconnect(iface, nullptr, this, nullptr);
}
}
@ -271,6 +272,8 @@ void PwNodeLinkTracker::onLinkGroupCreated(PwLinkGroup* linkGroup) {
|| (this->mNode->isSink() && linkGroup->inputNode() == this->mNode->id()))
{
auto* iface = PwLinkGroupIface::instance(linkGroup);
if (iface->target()->node()->isMonitor) return;
QObject::connect(iface, &QObject::destroyed, this, &PwNodeLinkTracker::onLinkGroupDestroyed);
this->mLinkGroups.push_back(iface);
emit this->linkGroupsChanged();

View file

@ -171,13 +171,13 @@ private:
ObjectModel<PwLinkGroupIface> mLinkGroups {this};
};
///! Tracks all link connections to a given node.
///! Tracks non-monitor link connections to a given node.
class PwNodeLinkTracker: public QObject {
Q_OBJECT;
// clang-format off
/// The node to track connections to.
Q_PROPERTY(qs::service::pipewire::PwNodeIface* node READ node WRITE setNode NOTIFY nodeChanged);
/// Link groups connected to the given node.
/// Link groups connected to the given node, excluding monitors.
///
/// If the node is a sink, links which target the node will be tracked.
/// If the node is a source, links which source the node will be tracked.