pulse: map stream index to endpoint

This commit is contained in:
Wim Taymans 2019-11-26 17:51:54 +01:00
parent 8335c50e1e
commit 2fddfb02bd
4 changed files with 15 additions and 5 deletions

View file

@ -644,8 +644,14 @@ static int set_mask(pa_context *c, struct global *g)
g->endpoint_info.client_id = atoi(str); g->endpoint_info.client_id = atoi(str);
if ((str = pw_properties_get(g->props, PW_KEY_DEVICE_ID)) != NULL) if ((str = pw_properties_get(g->props, PW_KEY_DEVICE_ID)) != NULL)
g->endpoint_info.device_id = atoi(str); 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); 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; events = &endpoint_events;
client_version = PW_VERSION_ENDPOINT_PROXY; client_version = PW_VERSION_ENDPOINT_PROXY;

View file

@ -344,6 +344,7 @@ struct pa_stream {
pa_format_info *req_formats[PA_MAX_FORMATS]; pa_format_info *req_formats[PA_MAX_FORMATS];
pa_format_info *format; pa_format_info *format;
uint32_t endpoint_id;
uint32_t stream_index; uint32_t stream_index;
pa_buffer_attr buffer_attr; pa_buffer_attr buffer_attr;

View file

@ -1493,7 +1493,7 @@ static void sink_input_callback(struct sink_input_data *d)
if (info == NULL) if (info == NULL)
return; return;
s = find_stream(d->context, g->id); s = find_stream(d->context, g->endpoint_info.node_id);
if (info->props) { if (info->props) {
if ((name = spa_dict_lookup(info->props, PW_KEY_MEDIA_NAME)) == NULL && 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) if (info == NULL)
return; return;
s = find_stream(d->context, g->id); s = find_stream(d->context, g->endpoint_info.node_id);
name = info->name; name = info->name;
if (name == NULL && info->props) { if (name == NULL && info->props) {

View file

@ -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); pw_stream_add_listener(s->stream, &s->stream_listener, &stream_events, s);
s->endpoint_id = SPA_ID_INVALID;
s->direction = PA_STREAM_NODIRECTION; s->direction = PA_STREAM_NODIRECTION;
s->state = PA_STREAM_UNCONNECTED; s->state = PA_STREAM_UNCONNECTED;
s->flags = 0; s->flags = 0;
@ -732,7 +733,9 @@ uint32_t pa_stream_get_index(PA_CONST pa_stream *s)
spa_assert(s); spa_assert(s);
spa_assert(s->refcount >= 1); spa_assert(s->refcount >= 1);
if (s->endpoint_id != SPA_ID_INVALID)
idx = s->endpoint_id;
else
idx = pw_stream_get_node_id(s->stream); idx = pw_stream_get_node_id(s->stream);
pw_log_debug("stream %p: index %u", s, idx); pw_log_debug("stream %p: index %u", s, idx);
return idx; return idx;