
In some cases we need to get a section as JSON, so that we can pass it down to the rules parser, while in other cases we neeed to get it as a table to use it natively, and in that case we even need to differentiate between it being an object, an array or an object with WpProperties. Make it also possible to optionally pass tables with default values to the functions so that we can get rid of cutils.get_config_section() as well.
43 lines
1.1 KiB
Lua
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
|
|
|
|
-- creates the virtual items defined in the JSON(virtual.conf)
|
|
|
|
log = Log.open_topic ("s-node")
|
|
|
|
config = {}
|
|
config.virtual_items = Conf.get_section_as_object ("virtual-items")
|
|
|
|
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
|