From 2e23d827793e56655ffd6be39b377578cef21661 Mon Sep 17 00:00:00 2001 From: Ashok Sidipotu Date: Tue, 11 Jan 2022 15:31:40 +0530 Subject: [PATCH 06/14] policy-endpoint-client.lua: fix record with endpoints The Role traversal of config data to take notice of the media class as well so that source and sink roles dont overstep on each other and pick up unexpected endpoints. --- src/scripts/policy-endpoint-client.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/scripts/policy-endpoint-client.lua b/src/scripts/policy-endpoint-client.lua index 6b96edf..e898e35 100644 --- a/src/scripts/policy-endpoint-client.lua +++ b/src/scripts/policy-endpoint-client.lua @@ -37,10 +37,12 @@ function scheduleRescan () end end -function findRole(role) +function findRole(role, tmc) if role and not config.roles[role] then for r, p in pairs(config.roles) do - if type(p.alias) == "table" then + -- default media class can be overridden in the role config data + mc = p["media.class"] or "Audio/Sink" + if (type(p.alias) == "table" and tmc == mc) then for i = 1, #(p.alias), 1 do if role == p.alias[i] then return r @@ -69,7 +71,7 @@ function findTargetEndpoint (node, media_class) end -- find highest priority endpoint by role - media_role = findRole(node.properties["media.role"]) + media_role = findRole(node.properties["media.role"], target_media_class) for si_target_ep in endpoints_om:iterate { Constraint { "role", "=", media_role, type = "pw-global" }, Constraint { "media.class", "=", target_media_class, type = "pw-global" }, -- 2.34.1