From 520c2a0e16f47d130566516471ccdfbf92469fd9 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 23 Oct 2020 18:23:02 +0200 Subject: [PATCH] context: only go to READY after registry is loaded This way we can lookup the node name when connecting a stream. See !314 --- pipewire-pulseaudio/src/context.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pipewire-pulseaudio/src/context.c b/pipewire-pulseaudio/src/context.c index 09e8af31f..bef510b5d 100644 --- a/pipewire-pulseaudio/src/context.c +++ b/pipewire-pulseaudio/src/context.c @@ -1541,9 +1541,6 @@ static void core_info(void *data, const struct pw_core_info *info) } c->core_info = pw_core_info_update(c->core_info, info); - - if (first) - pa_context_set_state(c, PA_CONTEXT_READY); } static void core_error(void *data, uint32_t id, int seq, int res, const char *message) @@ -1842,10 +1839,19 @@ pa_context_state_t pa_context_get_state(PA_CONST pa_context *c) return c->state; } +static void on_connected(pa_operation *o, void *userdata) +{ + pa_context *c = o->context; + pw_log_debug("context %p: connected", c); + pa_context_set_state(c, PA_CONTEXT_READY); + pa_operation_done(o); +} + SPA_EXPORT int pa_context_connect(pa_context *c, const char *server, pa_context_flags_t flags, const pa_spawn_api *api) { int res = 0; + pa_operation *o; pa_assert(c); pa_assert(c->refcount >= 1); @@ -1877,6 +1883,10 @@ int pa_context_connect(pa_context *c, const char *server, pa_context_flags_t fla &c->registry_listener, ®istry_events, c); + o = pa_operation_new(c, NULL, on_connected, sizeof(struct success_data)); + pa_operation_sync(o); + pa_operation_unref(o); + exit: pa_context_unref(c); @@ -1889,6 +1899,8 @@ void pa_context_disconnect(pa_context *c) pa_assert(c); pa_assert(c->refcount >= 1); + pw_log_debug("%p", c); + c->disconnect = true; if (c->registry) { pw_proxy_destroy((struct pw_proxy*)c->registry);