Files
wireplumber/src/scripts/node/create-virtual-item.lua
Julian Bouzas d2123827f7 scripts: use the event stack to handle virtual session items
This removes both the policy-virtual-client.lua and policy-virtual-device.lua
scripts, and creates a new linking/find-virtual-target.lua script to link
clients with virtual session items if one of them can be found. In addition to
this, this patch also ports the policy-virtual-client-links.lua into a new
scripts/rescan-virtual-links.lua to use the event stack. The idea is for the
scripts/link-target.lua to create all links but only activate non virtual links,
and for the scripts/rescan-virtual-links.lua to activate/deactivate virtual
links based on role priorities.
2023-04-17 07:48:18 -04:00

43 lines
1.1 KiB
Lua

-- WirePlumber
--
-- Copyright © 2021 Collabora Ltd.
-- @author Julian Bouzas <julian.bouzas@collabora.com>
--
-- SPDX-License-Identifier: MIT
-- Receive script arguments from config.lua
local defaults = {}
defaults.virtual_items = Json.Object {}
local config = {}
config.virtual_items = Conf.get_section (
"virtual-items", defaults.virtual_items):parse ()
function createVirtualItem (factory_name, properties)
-- create virtual item
local si_v = SessionItem ( factory_name )
if not si_v then
Log.warning (si_v, "could not create virtual item of type " .. factory_name)
return
end
-- configure virtual item
if not si_v:configure(properties) then
Log.warning(si_v, "failed to configure virtual item " .. properties.name)
return
end
-- activate and register virtual item
si_v:activate (Features.ALL, function (item)
item:register ()
Log.info(item, "registered virtual item " .. properties.name)
end)
end
for name, properties in pairs(config.virtual_items) do
properties["name"] = name
createVirtualItem ("si-audio-virtual", properties)
end