mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-02-04 22:30:28 +01:00
monitors/alsa: handle node activation failure
When node activation fails, it won't be created and its object-removed signal can be called with some properties missing. This breaks node name deduplication, causing error wplua: [string "alsa.lua"]:182: attempt to concatenate a nil value (local 'node_name') It occurs e.g. when switching ALSA device profile, while some application has opened the device with ALSA and is keeping it busy. Fix by handling the activation failure, and tolerating missing property in object-removed.
This commit is contained in:
parent
f4f495ee21
commit
1ddb473deb
1 changed files with 18 additions and 3 deletions
|
|
@ -108,6 +108,8 @@ function createNode(parent, id, obj_type, factory, properties)
|
|||
properties["node.name"] = name .. "." .. counter
|
||||
log:info ("deduplicating node name -> " .. properties["node.name"])
|
||||
end
|
||||
else
|
||||
log:info ("Creating node " .. properties["node.name"])
|
||||
end
|
||||
|
||||
-- and a nick
|
||||
|
|
@ -164,7 +166,16 @@ function createNode(parent, id, obj_type, factory, properties)
|
|||
|
||||
-- create the node
|
||||
local node = Node("adapter", properties)
|
||||
node:activate(Feature.Proxy.BOUND)
|
||||
node:activate(Feature.Proxy.BOUND, function (_, err)
|
||||
if err then
|
||||
log:warning ("Failed to create " .. properties ["node.name"]
|
||||
.. ": " .. tostring(err))
|
||||
|
||||
-- if it fails, object-removed gets called with missing
|
||||
-- properties, so clean up already here
|
||||
node_names_table [properties ["node.name"]] = nil
|
||||
end
|
||||
end)
|
||||
parent:store_managed_object(id, node)
|
||||
end
|
||||
|
||||
|
|
@ -179,8 +190,12 @@ function createDevice(parent, id, factory, properties)
|
|||
end
|
||||
|
||||
local node_name = node.properties["node.name"]
|
||||
log:info ("Removing node " .. node_name)
|
||||
node_names_table[node_name] = nil
|
||||
if node_name ~= nil then
|
||||
log:info ("Removing node " .. node_name)
|
||||
node_names_table[node_name] = nil
|
||||
else
|
||||
log:info ("Removing node with missing node.name")
|
||||
end
|
||||
end)
|
||||
device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND)
|
||||
parent:store_managed_object(id, device)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue