mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-19 08:57:14 -05:00
adapter: support custom prefix for device ports
Prefixes can be disabled for device ports by providing an empty string
This commit is contained in:
parent
375cc73b9d
commit
bb1f595b53
2 changed files with 23 additions and 5 deletions
|
|
@ -93,9 +93,9 @@ static void node_port_init(void *data, struct pw_impl_port *port)
|
||||||
const struct pw_properties *old;
|
const struct pw_properties *old;
|
||||||
enum pw_direction direction;
|
enum pw_direction direction;
|
||||||
struct pw_properties *new;
|
struct pw_properties *new;
|
||||||
const char *str, *path, *desc, *nick, *name, *node_name, *media_class, *prop_port_names;
|
const char *str, *path, *desc, *nick, *name, *node_name, *media_class, *prop_port_names, *override_device_prefix;
|
||||||
char position[8], *prefix;
|
char position[8], *prefix;
|
||||||
bool is_monitor, is_device, is_duplex, is_virtual, is_control = false;
|
bool is_monitor, is_device, is_duplex, is_virtual, is_control = false, no_device_port_prefix;
|
||||||
|
|
||||||
direction = pw_impl_port_get_direction(port);
|
direction = pw_impl_port_get_direction(port);
|
||||||
|
|
||||||
|
|
@ -123,6 +123,8 @@ static void node_port_init(void *data, struct pw_impl_port *port)
|
||||||
|
|
||||||
new = pw_properties_new(NULL, NULL);
|
new = pw_properties_new(NULL, NULL);
|
||||||
|
|
||||||
|
override_device_prefix = pw_properties_get(n->props, PW_KEY_NODE_DEVICE_PORT_NAME_PREFIX);
|
||||||
|
|
||||||
if (is_control)
|
if (is_control)
|
||||||
prefix = direction == PW_DIRECTION_INPUT ?
|
prefix = direction == PW_DIRECTION_INPUT ?
|
||||||
"control" : "notify";
|
"control" : "notify";
|
||||||
|
|
@ -134,7 +136,10 @@ static void node_port_init(void *data, struct pw_impl_port *port)
|
||||||
"input" : "capture";
|
"input" : "capture";
|
||||||
else if (is_device)
|
else if (is_device)
|
||||||
prefix = direction == PW_DIRECTION_INPUT ?
|
prefix = direction == PW_DIRECTION_INPUT ?
|
||||||
"playback" : is_monitor ? "monitor" : "capture";
|
override_device_prefix != NULL ?
|
||||||
|
strdup(override_device_prefix) : "playback"
|
||||||
|
: is_monitor ? "monitor" : override_device_prefix != NULL ?
|
||||||
|
strdup(override_device_prefix) : "capture";
|
||||||
else
|
else
|
||||||
prefix = direction == PW_DIRECTION_INPUT ?
|
prefix = direction == PW_DIRECTION_INPUT ?
|
||||||
"input" : is_monitor ? "monitor" : "output";
|
"input" : is_monitor ? "monitor" : "output";
|
||||||
|
|
@ -161,9 +166,14 @@ static void node_port_init(void *data, struct pw_impl_port *port)
|
||||||
|
|
||||||
pw_properties_setf(new, PW_KEY_OBJECT_PATH, "%s:%s_%d",
|
pw_properties_setf(new, PW_KEY_OBJECT_PATH, "%s:%s_%d",
|
||||||
path ? path : node_name, prefix, pw_impl_port_get_id(port));
|
path ? path : node_name, prefix, pw_impl_port_get_id(port));
|
||||||
|
|
||||||
|
no_device_port_prefix = is_device && !is_monitor
|
||||||
|
&& override_device_prefix != NULL && strlen(override_device_prefix) == 0;
|
||||||
|
|
||||||
if (is_control)
|
if (is_control)
|
||||||
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s", prefix);
|
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s", prefix);
|
||||||
|
else if (no_device_port_prefix)
|
||||||
|
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s", str);
|
||||||
else
|
else
|
||||||
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
|
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str);
|
||||||
|
|
||||||
|
|
@ -192,8 +202,13 @@ static void node_port_init(void *data, struct pw_impl_port *port)
|
||||||
if (spa_json_get_string(&it[1], v, sizeof(v)) <= 0)
|
if (spa_json_get_string(&it[1], v, sizeof(v)) <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (i == pw_impl_port_get_id(port) + 1 && strlen(v) > 0)
|
if (i == pw_impl_port_get_id(port) + 1 && strlen(v) > 0) {
|
||||||
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, v);
|
if (no_device_port_prefix) {
|
||||||
|
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s", v);
|
||||||
|
} else {
|
||||||
|
pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_impl_port_update_properties(port, &new->dict);
|
pw_impl_port_update_properties(port, &new->dict);
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,9 @@ extern "C" {
|
||||||
* but it will be triggered explicitly. */
|
* but it will be triggered explicitly. */
|
||||||
#define PW_KEY_NODE_CHANNELNAMES "node.channel-names" /**< names of node's
|
#define PW_KEY_NODE_CHANNELNAMES "node.channel-names" /**< names of node's
|
||||||
* channels (unrelated to positions) */
|
* channels (unrelated to positions) */
|
||||||
|
#define PW_KEY_NODE_DEVICE_PORT_NAME_PREFIX "node.device-port-name-prefix" /** override
|
||||||
|
* port name prefix for device ports, like capture and playback
|
||||||
|
* or disable the prefix completely if an empty string is provided */
|
||||||
|
|
||||||
/** Port keys */
|
/** Port keys */
|
||||||
#define PW_KEY_PORT_ID "port.id" /**< port id */
|
#define PW_KEY_PORT_ID "port.id" /**< port id */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue