From 33fc476cb37bee7a79de568cad44d90578510707 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Sun, 19 Nov 2023 17:52:20 +0200 Subject: [PATCH] s-linking: always rescan when the default targets change The "follow" setting was never really meant to disable reacting to default target changes. It is also not meant to disable moving normal streams to follow the default target. It is only meant to control whether streams with a 'target.object' that matches the default target will move or not to follow the default target changes (PulseAudio compat thing...) Even if we leave this code here, disabling the "follow" option may disable reacting to default target changes, but the streams will be moved anyway when there is some other change in the graph (i.e. in the next rescan) --- src/scripts/linking/move-follow.lua | 27 --------------------------- src/scripts/linking/rescan.lua | 7 +++++++ 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/scripts/linking/move-follow.lua b/src/scripts/linking/move-follow.lua index 47461d56..8af507f8 100644 --- a/src/scripts/linking/move-follow.lua +++ b/src/scripts/linking/move-follow.lua @@ -11,30 +11,6 @@ log = Log.open_topic ("s-linking") settings = require ("settings-linking") handles = {} -function handleFollowSetting (enable) - if (not handles.follow_hook) and (enable == true) then - handles.follow_hook = SimpleEventHook { - name = "linking/follow", - interests = { - EventInterest { - Constraint { "event.type", "=", "metadata-changed" }, - Constraint { "metadata.name", "=", "default" }, - Constraint { "event.subject.key", "c", "default.audio.source", - "default.audio.sink", "default.video.source" }, - }, - }, - execute = function (event) - local source = event:get_source () - source:call ("schedule-rescan", "linking") - end - } - handles.follow_hook:register () - elseif (handles.follow_hook) and (enable == false) then - handles.follow_hook:remove () - handles.follow_hook = nil - end -end - function handleMoveSetting (enable) if (not handles.move_hook) and (enable == true) then handles.move_hook = SimpleEventHook { @@ -58,8 +34,5 @@ function handleMoveSetting (enable) end end -settings:subscribe ("follow", handleFollowSetting) -handleFollowSetting (settings.follow) - settings:subscribe ("move", handleMoveSetting) handleMoveSetting (settings.move) diff --git a/src/scripts/linking/rescan.lua b/src/scripts/linking/rescan.lua index 505c4e15..8ce4cf84 100644 --- a/src/scripts/linking/rescan.lua +++ b/src/scripts/linking/rescan.lua @@ -179,6 +179,13 @@ SimpleEventHook { Constraint { "event.type", "=", "device-params-changed" }, Constraint { "event.subject.param-id", "=", "Route" }, }, + -- on any "default" target changed + EventInterest { + Constraint { "event.type", "=", "metadata-changed" }, + Constraint { "metadata.name", "=", "default" }, + Constraint { "event.subject.key", "c", "default.audio.source", + "default.audio.sink", "default.video.source" }, + }, }, execute = function (event) local source = event:get_source ()