monitors: sanitize node names to match media-session's behavior

This commit is contained in:
George Kiagiadakis 2021-02-15 19:18:07 +02:00
parent e92351b23b
commit 4ae15a14ac
3 changed files with 12 additions and 2 deletions

View file

@ -114,6 +114,9 @@ function createNode(parent, id, type, factory, properties)
.. "." ..
profile
-- sanitize name
name = name:gsub("([^%w_%-%.])", "_")
properties["node.name"] = name
-- deduplicate nodes with the same name
@ -127,10 +130,12 @@ function createNode(parent, id, type, factory, properties)
end
-- and a nick
properties["node.nick"] = properties["node.nick"]
local nick = properties["node.nick"]
or dev_props["device.nick"]
or dev_props["api.alsa.card.name"]
or dev_props["alsa.card_name"]
-- also sanitize nick, but allow all characters except :
properties["node.nick"] = nick:gsub("(:)", "_")
-- ensure the node has a description
if not properties["node.description"] then

View file

@ -56,11 +56,13 @@ function createNode(parent, id, type, factory, properties)
or "bluetooth-device"
-- set the node name
properties["node.name"] =
local name =
((factory:find("sink") and "bluez_output") or
(factory:find("source") and "bluez_input" or factory)) .. "." ..
(properties["api.bluez5.address"] or dev_props["device.name"]) .. "." ..
(properties["api.bluez5.profile"] or "unknown")
-- sanitize name
properties["node.name"] = name:gsub("([^%w_%-%.])", "_")
-- set priority
if not properties["priority.driver"] then

View file

@ -68,6 +68,9 @@ function createNode(parent, id, type, factory, properties)
dev_props["device.alias"] or
"v4l2-device")
-- sanitize name
name = name:gsub("([^%w_%-%.])", "_")
properties["node.name"] = name
-- deduplicate nodes with the same name