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 <pantelis.antoniou@konsulko.com>
This commit is contained in:
Pantelis Antoniou 2020-01-16 14:17:26 +02:00 committed by Wim Taymans
parent b5b3bfbe84
commit 193360abe6

View file

@ -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)