From b8bb7ce9da560c7d6e685143c8fa3c03fe0ca8b2 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Tue, 31 May 2022 10:55:10 +0300 Subject: [PATCH] impl-port: set port.alias if not already set This makes the video nodes have meaningful aliases on their ports, which make them look nicer in user-facing tools like wpctl and qpwgraph. --- src/pipewire/impl-port.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pipewire/impl-port.c b/src/pipewire/impl-port.c index 84e0c6394..081651bdd 100644 --- a/src/pipewire/impl-port.c +++ b/src/pipewire/impl-port.c @@ -1005,6 +1005,21 @@ int pw_impl_port_add(struct pw_impl_port *port, struct pw_impl_node *node) pw_properties_setf(port->properties, PW_KEY_PORT_NAME, "%s_%d", dir, port->port_id); } } + if (pw_properties_get(port->properties, PW_KEY_PORT_ALIAS) == NULL) { + const struct pw_properties *nprops; + const char *node_name; + + nprops = pw_impl_node_get_properties(node); + if ((node_name = pw_properties_get(nprops, PW_KEY_NODE_NICK)) == NULL && + (node_name = pw_properties_get(nprops, PW_KEY_NODE_DESCRIPTION)) == NULL && + (node_name = pw_properties_get(nprops, PW_KEY_NODE_NAME)) == NULL) + node_name = "node"; + + pw_properties_setf(port->properties, PW_KEY_PORT_ALIAS, "%s:%s", + node_name, + pw_properties_get(port->properties, PW_KEY_PORT_NAME)); + } + port->info.props = &port->properties->dict; if (control) {