scripts: fix minor issues with smart filters policy

The filter's destination target was not being found properly due to iterating
the matching rules table with ipairs instead of pairs... the later is meant to
be used with JSON objects. In addition, the filters were not being re-evaluated
and linked properly when a device node was removed, this is because of a typo in
the find-best-target.lua script.

See #501
This commit is contained in:
Julian Bouzas
2023-09-21 09:04:31 -04:00
parent 0c53f9b130
commit 06fa06ca5c
3 changed files with 3 additions and 4 deletions

View File

@@ -95,7 +95,7 @@ local function getFilterTarget (metadata, node, om)
end end
-- Make sure the target node properties match all rules -- Make sure the target node properties match all rules
for key, val in ipairs(match_rules) do for key, val in pairs(match_rules) do
if n_target.properties[key] ~= val then if n_target.properties[key] ~= val then
goto skip_target goto skip_target
end end
@@ -381,7 +381,7 @@ function module.get_filter_from_target (direction, si_target)
if v.direction == direction and if v.direction == direction and
v.enabled and v.enabled and
v.target ~= nil and v.target ~= nil and
v.target.id == target.id then v.target.id == si_target.id then
return v.main_si return v.main_si
end end
end end

View File

@@ -44,7 +44,7 @@ SimpleEventHook {
} do } do
local target_props = target.properties local target_props = target.properties
local target_node_id = target_props ["node.id"] local target_node_id = target_props ["node.id"]
local si_target_node = si:get_associated_proxy ("node") local si_target_node = target:get_associated_proxy ("node")
local si_target_link_group = si_target_node.properties ["node.link-group"] local si_target_link_group = si_target_node.properties ["node.link-group"]
local priority = tonumber (target_props ["priority.session"]) or 0 local priority = tonumber (target_props ["priority.session"]) or 0

View File

@@ -151,7 +151,6 @@ SimpleEventHook {
EventInterest { EventInterest {
Constraint { "event.type", "c", "session-item-added", "session-item-removed" }, Constraint { "event.type", "c", "session-item-added", "session-item-removed" },
Constraint { "event.session-item.interface", "=", "linkable" }, Constraint { "event.session-item.interface", "=", "linkable" },
Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node", "si-audio-virtual" },
}, },
-- on device Routes changed -- on device Routes changed
EventInterest { EventInterest {