Skip to content

policy-node: make streams follow default sink/src changes

P V requested to merge pvir/pipewire:policy-default-move-b into master

The motivation is to have both existing and new streams that have been created without explicit target node, to be directed to the same devices at all times. To achieve this:

Consider what find_node returns as the "default node".

Consider streams that auto+reconnect and don't have an explicit target, as following default. In rescan, if the default node has changed, relink such streams to the new default.

Remove the old code that explicitly moved streams when the default.* metadata changed, as it implements a similar thing but in a less robust way (may fail to do what's intended, because the default device metadata is commonly unset, or the metadata callback comes before session_create has seen the new nodes).

Enable this feature based on "policy-node.streams-follow-default" property. Allow setting the property also by loading the streams-follow-default module. Enable it by default only for the with-pulseaudio module group.


This fixes issues as e.g. playing streams that in pavucontrol look like they are playing on the fallback device, don't always move when you select a new fallback device there (because there was no previous default.* metadata set and it was decided based on priority), or playing streams don't move to a newly appeared device when default-nodes restores it as a default (because metadata and session_create callbacks don't come in the necessary order).

I thought about a few different ways to fix these, but this seemed cleanest. Better suggestions welcome of course.

Edited by P V

Merge request reports