From 7670ee7eec2305b697c41b921628eb9c6463596e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 6 May 2019 17:05:05 +0200 Subject: [PATCH] core: destroy all resources on hello Destroy all resources (except the core) for a client when it does a hello. This typically needs to be done after passing the connection fd from one client to another. --- src/pipewire/core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pipewire/core.c b/src/pipewire/core.c index c0bf02786..48ffaa14a 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -102,13 +102,23 @@ static const struct pw_resource_events resource_events = { .destroy = destroy_registry_resource }; +static int destroy_resource(void *object, void *data) +{ + struct pw_resource *resource = object; + if (resource && resource != resource->client->core_resource) + pw_resource_destroy(resource); + return 0; +} + static void core_hello(void *object) { struct pw_resource *resource = object; + struct pw_client *client = resource->client; struct pw_core *this = resource->core; - pw_log_debug("core %p: hello from source %p", this, resource); - resource->client->n_types = 0; + pw_log_debug("core %p: hello from resource %p", this, resource); + client->n_types = 0; + pw_map_for_each(&client->objects, destroy_resource, client); this->info.change_mask = PW_CORE_CHANGE_MASK_ALL; pw_core_resource_info(resource, &this->info);