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

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 commit is contained in:
Pauli Virtanen 2021-01-17 00:31:47 +02:00 committed by Wim Taymans
parent 419d0ad7b6
commit b10123eceb
5 changed files with 103 additions and 52 deletions

View file

@ -84,6 +84,7 @@ int sm_default_nodes_start(struct sm_media_session *sess);
int sm_default_profile_start(struct sm_media_session *sess);
int sm_default_routes_start(struct sm_media_session *sess);
int sm_restore_stream_start(struct sm_media_session *sess);
int sm_streams_follow_default_start(struct sm_media_session *sess);
int sm_alsa_midi_start(struct sm_media_session *sess);
int sm_v4l2_monitor_start(struct sm_media_session *sess);
int sm_libcamera_monitor_start(struct sm_media_session *sess);
@ -2227,6 +2228,7 @@ static const struct {
{ "default-profile", "restore default profiles", sm_default_profile_start, NULL },
{ "default-routes", "restore default route", sm_default_routes_start, NULL },
{ "restore-stream", "restore stream settings", sm_restore_stream_start, NULL },
{ "streams-follow-default", "move streams when default changes", sm_streams_follow_default_start, NULL },
{ "alsa-seq", "alsa seq midi support", sm_alsa_midi_start, NULL },
{ "alsa-monitor", "alsa card udev detection", sm_alsa_monitor_start, NULL },
{ "v4l2", "video for linux udev detection", sm_v4l2_monitor_start, NULL },