From 95f87301c74d2f49b218e124ac8186a5b3a1739d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 10 Jan 2023 17:11:43 +0100 Subject: [PATCH] clarify PIPEWIRE_NODE PIPEWIRE_NODE is mapped to TARGET_OBJECT so it contains the serial or the node name. Make sure pw-stream maps this to TARGET_OBJECT. Make JACK use the PIPEWIRE_NODE for serial or node.name. --- README.md | 3 ++- pipewire-jack/src/pipewire-jack.c | 16 ++++++++-------- src/pipewire/stream.c | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d1a90e2e2..612f500e7 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,8 @@ applications: samplerate. This function will attempt to change the graph samplerate to `denom` and use the specified `num` as the buffer size. -* `PIPEWIRE_NODE=` to request a link to the specified node +* `PIPEWIRE_NODE=` to request a link to the specified node. The + id can be a node.name or object.serial of the target node. ### Using tools diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index b8e84915d..8ae8b23a2 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -5591,16 +5591,13 @@ const char ** jack_get_ports (jack_client_t *client, struct object *o; struct pw_array tmp; const char *str; - uint32_t i, count, id; + uint32_t i, count; int r; regex_t port_regex, type_regex; spa_return_val_if_fail(c != NULL, NULL); - if ((str = getenv("PIPEWIRE_NODE")) != NULL) - id = pw_properties_parse_int(str); - else - id = SPA_ID_INVALID; + str = getenv("PIPEWIRE_NODE"); if (port_name_pattern && port_name_pattern[0]) { if ((r = regcomp(&port_regex, port_name_pattern, REG_EXTENDED | REG_NOSUB)) != 0) { @@ -5615,7 +5612,7 @@ const char ** jack_get_ports (jack_client_t *client, } } - pw_log_debug("%p: ports id:%d name:\"%s\" type:\"%s\" flags:%08lx", c, id, + pw_log_debug("%p: ports target:%s name:\"%s\" type:\"%s\" flags:%08lx", c, str, port_name_pattern, type_name_pattern, flags); pthread_mutex_lock(&c->context.lock); @@ -5631,8 +5628,11 @@ const char ** jack_get_ports (jack_client_t *client, continue; if (!SPA_FLAG_IS_SET(o->port.flags, flags)) continue; - if (id != SPA_ID_INVALID && o->port.node_id != id) - continue; + if (str != NULL && o->port.node != NULL) { + if (!spa_strstartswith(o->port.name, str) && + o->port.node->serial != atoll(str)) + continue; + } if (port_name_pattern && port_name_pattern[0]) { bool match; diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 3b0d8adb4..cfd7bd15d 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -1892,7 +1892,7 @@ pw_stream_connect(struct pw_stream *stream, if (target_id != PW_ID_ANY) pw_properties_setf(stream->properties, PW_KEY_NODE_TARGET, "%d", target_id); else if ((str = getenv("PIPEWIRE_NODE")) != NULL) - pw_properties_set(stream->properties, PW_KEY_NODE_TARGET, str); + pw_properties_set(stream->properties, PW_KEY_TARGET_OBJECT, str); if ((flags & PW_STREAM_FLAG_AUTOCONNECT) && pw_properties_get(stream->properties, PW_KEY_NODE_AUTOCONNECT) == NULL) { str = getenv("PIPEWIRE_AUTOCONNECT");