From 6b09a304dc5c20ab1144a83db6b128c3f6296b8f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 17 Jun 2022 15:40:56 +0200 Subject: [PATCH] adapter: name control ports as "control" --- src/modules/module-adapter/adapter.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index 297462a73..3c2cd56b9 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -95,7 +95,7 @@ static void node_port_init(void *data, struct pw_impl_port *port) struct pw_properties *new; const char *str, *path, *desc, *nick, *name, *node_name, *media_class; char position[8], *prefix; - bool is_monitor, is_device, is_duplex, is_virtual; + bool is_monitor, is_device, is_duplex, is_virtual, is_control = false; direction = pw_impl_port_get_direction(port); @@ -105,6 +105,9 @@ static void node_port_init(void *data, struct pw_impl_port *port) if (!is_monitor && direction != n->direction) return; + if ((str = pw_properties_get(old, PW_KEY_FORMAT_DSP)) != NULL) + is_control = spa_streq(str, "8 bit raw midi"); + path = pw_properties_get(n->props, PW_KEY_OBJECT_PATH); media_class = pw_properties_get(n->props, PW_KEY_MEDIA_CLASS); @@ -120,7 +123,10 @@ static void node_port_init(void *data, struct pw_impl_port *port) new = pw_properties_new(NULL, NULL); - if (is_duplex) + if (is_control) + prefix = direction == PW_DIRECTION_INPUT ? + "control" : "notify"; + else if (is_duplex) prefix = direction == PW_DIRECTION_INPUT ? "playback" : "capture"; else if (is_virtual) @@ -156,13 +162,20 @@ static void node_port_init(void *data, struct pw_impl_port *port) pw_properties_setf(new, PW_KEY_OBJECT_PATH, "%s:%s_%d", path ? path : node_name, prefix, pw_impl_port_get_id(port)); - pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str); + if (is_control) + pw_properties_setf(new, PW_KEY_PORT_NAME, "%s", prefix); + else + pw_properties_setf(new, PW_KEY_PORT_NAME, "%s_%s", prefix, str); if ((node_name = nick) == NULL && (node_name = desc) == NULL && (node_name = name) == NULL) node_name = "node"; - pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s_%s", + if (is_control) + pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s", + node_name, prefix); + else + pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s_%s", node_name, prefix, str); pw_impl_port_update_properties(port, &new->dict);