mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-08 12:48:03 +02:00
policy-endpint: add support for stream audio nodes without media.role
If a stream audio node does not have the 'media.role' property set, the policy will asign the 'Default' media role name to it. In addition to this, if the 'Default' endpoint can not be found, the policy will link the stream audio node with the lowest priority endpoint. Video nodes will always be handled by policy-node.lua, and they will never be handled by policy-endpoint-client.lua This allows users to assign a particular endpoint for streams that don't have the 'media.role' property set.
This commit is contained in:
parent
453a7e9325
commit
e495d4920d
2 changed files with 22 additions and 9 deletions
|
|
@ -39,6 +39,7 @@ end
|
|||
|
||||
function findRole(role, tmc)
|
||||
if role and not config.roles[role] then
|
||||
-- find the role with matching alias
|
||||
for r, p in pairs(config.roles) do
|
||||
-- default media class can be overridden in the role config data
|
||||
mc = p["media.class"] or "Audio/Sink"
|
||||
|
|
@ -50,11 +51,24 @@ function findRole(role, tmc)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- otherwise get the lowest priority role
|
||||
local lowest_priority_p = nil
|
||||
local lowest_priority_r = nil
|
||||
for r, p in pairs(config.roles) do
|
||||
mc = p["media.class"] or "Audio/Sink"
|
||||
if tmc == mc and (lowest_priority_p == nil or
|
||||
p.priority < lowest_priority_p.priority) then
|
||||
lowest_priority_p = p
|
||||
lowest_priority_r = r
|
||||
end
|
||||
end
|
||||
return lowest_priority_r
|
||||
end
|
||||
return role
|
||||
end
|
||||
|
||||
function findTargetEndpoint (node, media_class)
|
||||
function findTargetEndpoint (node, media_class, role)
|
||||
local target_class_assoc = {
|
||||
["Stream/Input/Audio"] = "Audio/Source",
|
||||
["Stream/Output/Audio"] = "Audio/Sink",
|
||||
|
|
@ -71,7 +85,7 @@ function findTargetEndpoint (node, media_class)
|
|||
end
|
||||
|
||||
-- find highest priority endpoint by role
|
||||
media_role = findRole(node.properties["media.role"], target_media_class)
|
||||
media_role = findRole(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" },
|
||||
|
|
@ -140,8 +154,7 @@ function checkLinkable (si)
|
|||
end
|
||||
|
||||
-- Determine if we can handle item by this policy
|
||||
local media_role = node.properties["media.role"]
|
||||
if endpoints_om:get_n_objects () == 0 or media_role == nil then
|
||||
if endpoints_om:get_n_objects () == 0 then
|
||||
Log.debug (si, "item won't be handled by this policy")
|
||||
return false
|
||||
end
|
||||
|
|
@ -156,12 +169,12 @@ function handleLinkable (si)
|
|||
|
||||
local node = si:get_associated_proxy ("node")
|
||||
local media_class = node.properties["media.class"] or ""
|
||||
local media_role = node.properties["media.role"] or ""
|
||||
local media_role = node.properties["media.role"] or "Default"
|
||||
Log.info (si, "handling item " .. tostring(node.properties["node.name"]) ..
|
||||
" with role " .. media_role)
|
||||
|
||||
-- find proper target endpoint
|
||||
local si_target_ep = findTargetEndpoint (node, media_class)
|
||||
local si_target_ep = findTargetEndpoint (node, media_class, media_role)
|
||||
if not si_target_ep then
|
||||
Log.info (si, "... target endpoint not found")
|
||||
return
|
||||
|
|
@ -223,7 +236,7 @@ endpoints_om = ObjectManager { Interest { type = "SiEndpoint" }}
|
|||
linkables_om = ObjectManager { Interest { type = "SiLinkable",
|
||||
-- only handle si-audio-adapter and si-node
|
||||
Constraint {
|
||||
"item.factory.name", "c", "si-audio-adapter", "si-node", type = "pw-global" },
|
||||
"item.factory.name", "=", "si-audio-adapter", type = "pw-global" },
|
||||
}
|
||||
}
|
||||
links_om = ObjectManager { Interest { type = "SiLink",
|
||||
|
|
|
|||
|
|
@ -517,8 +517,8 @@ function checkLinkable(si)
|
|||
end
|
||||
|
||||
-- Determine if we can handle item by this policy
|
||||
local media_role = si_props["media.role"]
|
||||
if endpoints_om:get_n_objects () > 0 and media_role ~= nil then
|
||||
if endpoints_om:get_n_objects () > 0 and
|
||||
si_props["item.factory.name"] == "si-audio-adapter" then
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue