diff --git a/pipewire-pulseaudio/src/context.c b/pipewire-pulseaudio/src/context.c index c84fba14f..0ebea4ef7 100644 --- a/pipewire-pulseaudio/src/context.c +++ b/pipewire-pulseaudio/src/context.c @@ -644,8 +644,14 @@ static int set_mask(pa_context *c, struct global *g) g->endpoint_info.client_id = atoi(str); if ((str = pw_properties_get(g->props, PW_KEY_DEVICE_ID)) != NULL) g->endpoint_info.device_id = atoi(str); - if ((str = pw_properties_get(g->props, PW_KEY_NODE_ID)) != NULL) + if ((str = pw_properties_get(g->props, PW_KEY_NODE_ID)) != NULL) { + pa_stream *s; g->endpoint_info.node_id = atoi(str); + spa_list_for_each(s, &c->streams, link) { + if (pw_stream_get_node_id(s->stream) == g->endpoint_info.node_id) + s->endpoint_id = g->id; + } + } events = &endpoint_events; client_version = PW_VERSION_ENDPOINT_PROXY; diff --git a/pipewire-pulseaudio/src/internal.h b/pipewire-pulseaudio/src/internal.h index 79e60b7ee..fd80d8b8a 100644 --- a/pipewire-pulseaudio/src/internal.h +++ b/pipewire-pulseaudio/src/internal.h @@ -344,6 +344,7 @@ struct pa_stream { pa_format_info *req_formats[PA_MAX_FORMATS]; pa_format_info *format; + uint32_t endpoint_id; uint32_t stream_index; pa_buffer_attr buffer_attr; diff --git a/pipewire-pulseaudio/src/introspect.c b/pipewire-pulseaudio/src/introspect.c index f20b7d361..9fd322386 100644 --- a/pipewire-pulseaudio/src/introspect.c +++ b/pipewire-pulseaudio/src/introspect.c @@ -1493,7 +1493,7 @@ static void sink_input_callback(struct sink_input_data *d) if (info == NULL) return; - s = find_stream(d->context, g->id); + s = find_stream(d->context, g->endpoint_info.node_id); if (info->props) { if ((name = spa_dict_lookup(info->props, PW_KEY_MEDIA_NAME)) == NULL && @@ -1793,7 +1793,7 @@ static void source_output_callback(struct source_output_data *d) if (info == NULL) return; - s = find_stream(d->context, g->id); + s = find_stream(d->context, g->endpoint_info.node_id); name = info->name; if (name == NULL && info->props) { diff --git a/pipewire-pulseaudio/src/stream.c b/pipewire-pulseaudio/src/stream.c index 0fa3bdce6..f5207fc56 100644 --- a/pipewire-pulseaudio/src/stream.c +++ b/pipewire-pulseaudio/src/stream.c @@ -561,6 +561,7 @@ static pa_stream* stream_new(pa_context *c, const char *name, pw_stream_add_listener(s->stream, &s->stream_listener, &stream_events, s); + s->endpoint_id = SPA_ID_INVALID; s->direction = PA_STREAM_NODIRECTION; s->state = PA_STREAM_UNCONNECTED; s->flags = 0; @@ -732,8 +733,10 @@ uint32_t pa_stream_get_index(PA_CONST pa_stream *s) spa_assert(s); spa_assert(s->refcount >= 1); - - idx = pw_stream_get_node_id(s->stream); + if (s->endpoint_id != SPA_ID_INVALID) + idx = s->endpoint_id; + else + idx = pw_stream_get_node_id(s->stream); pw_log_debug("stream %p: index %u", s, idx); return idx; }