From 193360abe699c29257a5fb439eda4c9f511a94c4 Mon Sep 17 00:00:00 2001 From: Pantelis Antoniou Date: Thu, 16 Jan 2020 14:17:26 +0200 Subject: [PATCH] pipewire-cli: Immediately bind the object on creation Immediately bind the global object upon creation. This allows to iterate over them without having to wait for the bind to be completed asynchronously. Signed-off-by: Pantelis Antoniou --- src/tools/pw-cli.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tools/pw-cli.c b/src/tools/pw-cli.c index fdd6688c3..f4f5e0984 100644 --- a/src/tools/pw-cli.c +++ b/src/tools/pw-cli.c @@ -302,6 +302,9 @@ static int print_global(void *obj, void *data) return 0; } + +static bool bind_global(struct remote_data *rd, struct global *global, char **error); + static void registry_event_global(void *data, uint32_t id, uint32_t permissions, const char *type, uint32_t version, const struct spa_dict *props) @@ -309,6 +312,8 @@ static void registry_event_global(void *data, uint32_t id, struct remote_data *rd = data; struct global *global; size_t size; + char *error; + bool ret; global = calloc(1, sizeof(struct global)); global->rd = rd; @@ -325,6 +330,13 @@ static void registry_event_global(void *data, uint32_t id, while (id > size) pw_map_insert_at(&rd->globals, size++, NULL); pw_map_insert_at(&rd->globals, id, global); + + /* immediately bind the object always */ + ret = bind_global(rd, global, &error); + if (!ret) { + fprintf(stdout, "Error: \"%s\"\n", error); + free(error); + } } static int destroy_global(void *obj, void *data)