mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-01-26 05:10:24 +01:00
With the latest changes, we can implement the "after-events" type with external code that pushes a very low priority event that is the "rescan" event.
66 lines
2 KiB
Lua
66 lines
2 KiB
Lua
-- WirePlumber
|
|
--
|
|
-- Copyright © 2022 Collabora Ltd.
|
|
--
|
|
-- SPDX-License-Identifier: MIT
|
|
--
|
|
-- Move & follow settings handlers. If the relevant settings are enabled,
|
|
-- install hooks that will schedule a rescan of the graph when needed
|
|
|
|
local config = require ("policy-config")
|
|
local handles = {}
|
|
|
|
function handleFollowSetting (enable)
|
|
if (not handles.follow_hook) and (enable == true) then
|
|
handles.follow_hook = SimpleEventHook {
|
|
name = "follow@policy-desktop",
|
|
priority = HookPriority.NORMAL,
|
|
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")
|
|
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 {
|
|
name = "move@policy-desktop",
|
|
priority = HookPriority.NORMAL,
|
|
interests = {
|
|
EventInterest {
|
|
Constraint { "event.type", "=", "metadata-changed" },
|
|
Constraint { "metadata.name", "=", "default" },
|
|
Constraint { "event.subject.key", "c", "target.node", "target.object" },
|
|
},
|
|
},
|
|
execute = function (event)
|
|
local source = event:get_source ()
|
|
source:call ("schedule-rescan")
|
|
end
|
|
}
|
|
handles.move_hook:register()
|
|
elseif (handles.move_hook) and (enable == false) then
|
|
handles.move_hook:remove ()
|
|
handles.move_hook = nil
|
|
end
|
|
end
|
|
|
|
config:subscribe ("follow", handleFollowSetting)
|
|
handleFollowSetting (config.follow)
|
|
|
|
config:subscribe ("move", handleMoveSetting)
|
|
handleMoveSetting (config.move)
|