mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-08 20:59:09 +02:00
linking: handle 'target.linger' property
When set to 'true', the node will remain alive without any error produced if it cannot be linked to its specified target; in all other cases, an error will be produced and the node will be destroyed.
This commit is contained in:
parent
970050d3b5
commit
8ac96f4a37
4 changed files with 35 additions and 19 deletions
|
|
@ -303,4 +303,18 @@ function putils.haveAvailableRoutes (si_props)
|
|||
return false
|
||||
end
|
||||
|
||||
function putils.sendClientError (event, node, message)
|
||||
local source = event:get_source ()
|
||||
local client_id = node.properties ["client.id"]
|
||||
if client_id then
|
||||
local clients_om = source:call ("get-object-manager", "client")
|
||||
local client = clients_om:lookup {
|
||||
Constraint { "bound-id", "=", client_id, type = "gobject" }
|
||||
}
|
||||
if client then
|
||||
client:send_error (node ["bound-id"], -2, message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return putils
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ SimpleEventHook {
|
|||
local node = si:get_associated_proxy ("node")
|
||||
local dont_fallback = cutils.parseBool (node.properties ["target.dont-fallback"])
|
||||
local dont_move = cutils.parseBool (node.properties ["target.dont-move"])
|
||||
local linger = cutils.parseBool (node.properties ["target.linger"])
|
||||
local target_key
|
||||
local target_value = nil
|
||||
local node_defined = false
|
||||
|
|
@ -113,7 +114,14 @@ SimpleEventHook {
|
|||
si_flags.can_passthrough = can_passthrough
|
||||
event:set_data ("target", target)
|
||||
elseif target_value and dont_fallback then
|
||||
log:info(si, "... waiting for defined target as dont-fallback is set")
|
||||
-- send error to client and destroy node if linger is not set
|
||||
if not linger then
|
||||
putils.sendClientError (event, node, "defined target not found")
|
||||
node:request_destroy ()
|
||||
log:info(si, "... destroyed node as defined target was not found")
|
||||
else
|
||||
log:info(si, "... waiting for defined target as dont-fallback is set")
|
||||
end
|
||||
event:stop_processing ()
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ SimpleEventHook {
|
|||
|
||||
local node = si:get_associated_proxy ("node")
|
||||
local dont_fallback = cutils.parseBool (node.properties ["target.dont-fallback"])
|
||||
local linger = cutils.parseBool (node.properties ["target.linger"])
|
||||
local target_picked = false
|
||||
local allow_fallback
|
||||
|
||||
|
|
@ -64,7 +65,7 @@ SimpleEventHook {
|
|||
passthrough_compatible, can_passthrough =
|
||||
putils.checkPassthroughCompatibility (si, target)
|
||||
if putils.canLink (si_props, target) and passthrough_compatible then
|
||||
target_picked = true;
|
||||
target_picked = true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -77,7 +78,14 @@ SimpleEventHook {
|
|||
si_flags.can_passthrough = can_passthrough
|
||||
event:set_data ("target", target)
|
||||
elseif is_smart_filter and dont_fallback then
|
||||
log:info(si, "... waiting for smart filter defined target as dont-fallback is set")
|
||||
-- send error to client and destroy node if linger is not set
|
||||
if not linger then
|
||||
putils.sendClientError (event, node, "smart filter defined target not found")
|
||||
node:request_destroy ()
|
||||
log:info(si, "... destroyed node as smart filter defined target was not found")
|
||||
else
|
||||
log:info(si, "... waiting for smart filter defined target as dont-fallback is set")
|
||||
end
|
||||
event:stop_processing ()
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -100,22 +100,8 @@ SimpleEventHook {
|
|||
return
|
||||
end
|
||||
|
||||
local client_id = node.properties ["client.id"]
|
||||
if client_id then
|
||||
local clients_om = source:call ("get-object-manager", "client")
|
||||
local client = clients_om:lookup {
|
||||
Constraint { "bound-id", "=", client_id, type = "gobject" }
|
||||
}
|
||||
local message
|
||||
if reconnect then
|
||||
message = "no target node available"
|
||||
else
|
||||
message = "target not found"
|
||||
end
|
||||
if client then
|
||||
client:send_error (node ["bound-id"], -2, message)
|
||||
end
|
||||
end
|
||||
putils.sendClientError (event, node,
|
||||
reconnect and "no target node available" or "target not found")
|
||||
|
||||
if not reconnect then
|
||||
log:info (si, "... destroy node")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue