mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
stream: fix connect by name
Look up the node id for the given device name and use that to connect.
This commit is contained in:
parent
6df567e6d4
commit
520a9831e7
3 changed files with 12 additions and 3 deletions
|
|
@ -261,6 +261,7 @@ struct pa_context {
|
|||
};
|
||||
|
||||
struct global *pa_context_find_global(pa_context *c, uint32_t id);
|
||||
struct global *pa_context_find_global_by_name(pa_context *c, uint32_t mask, const char *name);
|
||||
|
||||
#define MAX_BUFFERS 64
|
||||
#define MASK_BUFFERS (MAX_BUFFERS-1)
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ static void sink_callback(struct sink_data *d)
|
|||
ii[0].encoding = PA_ENCODING_PCM;
|
||||
ii[0].plist = pa_proplist_new();
|
||||
ip[0] = ii;
|
||||
pa_channel_map_init_auto(&i.channel_map, 2, PA_CHANNEL_MAP_DEFAULT);
|
||||
i.formats = ip;
|
||||
d->cb(d->context, &i, 0, d->userdata);
|
||||
}
|
||||
|
|
@ -169,7 +170,7 @@ static void sink_info(pa_operation *o, void *userdata)
|
|||
pa_operation_done(o);
|
||||
}
|
||||
|
||||
static struct global *find_type_by_name(pa_context *c, uint32_t mask, const char *name)
|
||||
struct global *pa_context_find_global_by_name(pa_context *c, uint32_t mask, const char *name)
|
||||
{
|
||||
struct global *g;
|
||||
const char *str;
|
||||
|
|
@ -200,7 +201,7 @@ pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name,
|
|||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
|
||||
|
||||
if ((g = find_type_by_name(c, PA_SUBSCRIPTION_MASK_SINK, name)) == NULL)
|
||||
if ((g = pa_context_find_global_by_name(c, PA_SUBSCRIPTION_MASK_SINK, name)) == NULL)
|
||||
return NULL;
|
||||
|
||||
ensure_global(c, g);
|
||||
|
|
|
|||
|
|
@ -178,7 +178,8 @@ static void dump_buffer_attr(pa_stream *s, pa_buffer_attr *attr)
|
|||
static void configure_buffers(pa_stream *s)
|
||||
{
|
||||
s->buffer_attr.maxlength = s->maxsize;
|
||||
s->buffer_attr.prebuf = s->buffer_attr.minreq;
|
||||
if (s->buffer_attr.prebuf == -1)
|
||||
s->buffer_attr.prebuf = s->buffer_attr.minreq;
|
||||
s->buffer_attr.fragsize = s->buffer_attr.minreq;
|
||||
dump_buffer_attr(s, &s->buffer_attr);
|
||||
}
|
||||
|
|
@ -772,6 +773,8 @@ static int create_stream(pa_stream_direction_t direction,
|
|||
struct pw_properties *props;
|
||||
uint32_t sample_rate = 0, stride = 0;
|
||||
const char *str;
|
||||
char devid[16];
|
||||
struct global *g;
|
||||
|
||||
spa_assert(s);
|
||||
spa_assert(s->refcount >= 1);
|
||||
|
|
@ -831,6 +834,10 @@ static int create_stream(pa_stream_direction_t direction,
|
|||
|
||||
if (dev == NULL)
|
||||
dev = getenv("PIPEWIRE_NODE");
|
||||
else if ((g = pa_context_find_global_by_name(s->context, PA_SUBSCRIPTION_MASK_SINK, dev)) != NULL) {
|
||||
snprintf(devid, 15, "%d", g->id);
|
||||
dev = devid;
|
||||
}
|
||||
|
||||
props = (struct pw_properties *) pw_stream_get_properties(s->stream);
|
||||
pw_properties_setf(props, "node.latency", "%u/%u",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue