| 1 |
-- WirePlumber |
| 2 |
-- |
| 3 |
-- Copyright © 2025 The WirePlumber project contributors |
| 4 |
-- @author Julian Bouzas <[email protected]> |
| 5 |
-- |
| 6 |
-- SPDX-License-Identifier: MIT |
| 7 |
|
| 8 |
log = Log.open_topic("s-node") |
| 9 |
|
| 10 |
config = {} |
| 11 |
config.rules = Conf.get_section_as_json ("node.filter-graph.rules", Json.Array{}) |
| 12 |
|
| 13 |
function setNodeFilterGraphParams (node, graph_params) |
| 14 |
local pod = Pod.Object { |
| 15 |
"Spa:Pod:Object:Param:Props", "Props", |
| 16 |
params = Pod.Struct (graph_params) |
| 17 |
} |
| 18 |
node:set_params("Props", pod) |
| 19 |
end |
| 20 |
|
| 21 |
|
| 22 |
SimpleEventHook { |
| 23 |
name = "node/create-filter-graph", |
| 24 |
interests = { |
| 25 |
EventInterest { |
| 26 |
Constraint { "event.type", "=", "node-added" }, |
| 27 |
Constraint { "library.name", "=", "audioconvert/libspa-audioconvert", type = "pw" }, |
| 28 |
}, |
| 29 |
}, |
| 30 |
execute = function(event) |
| 31 |
local node = event:get_subject() |
| 32 |
|
| 33 |
JsonUtils.match_rules (config.rules, node.properties, function (action, value) |
| 34 |
|
| 35 |
if action == "create-filter-graph" then |
| 36 |
local graphs = value:parse (1) |
| 37 |
|
| 38 |
local graph_params = {} |
| 39 |
for idx, val in ipairs (graphs) do |
| 40 |
local index = tonumber(idx) - 1 |
| 41 |
local key = "audioconvert.filter-graph." .. tostring (index) |
| 42 |
|
| 43 |
log:info (node, "setting node filter graph param '" .. key .. "' to: " .. val) |
| 44 |
|
| 45 |
table.insert(graph_params, key) |
| 46 |
table.insert(graph_params, val) |
| 47 |
end |
| 48 |
|
| 49 |
setNodeFilterGraphParams (node, graph_params) |
| 50 |
end |
| 51 |
end) |
| 52 |
end |
| 53 |
}:register() |