diff options
author | Wim Taymans <wtaymans@redhat.com> | 2019-05-10 12:09:26 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2019-05-10 12:09:26 +0200 |
commit | e0eeedc369d03c3531d052a8cc95e361ff7d16ab (patch) | |
tree | 5b262d01c1cd766db8aaeec0d1e139f9788a65ef | |
parent | 5d2f0f5182cd59e83629e9727f915d7aebb61bb9 (diff) |
core: don't send remove_id in hello
The hello method should also destroy the resources for a client but not
send a remove_id for them.
-rw-r--r-- | src/pipewire/core.c | 4 | ||||
-rw-r--r-- | src/pipewire/interfaces.h | 3 | ||||
-rw-r--r-- | src/pipewire/private.h | 2 | ||||
-rw-r--r-- | src/pipewire/remote.c | 8 | ||||
-rw-r--r-- | src/pipewire/resource.c | 2 |
5 files changed, 14 insertions, 5 deletions
diff --git a/src/pipewire/core.c b/src/pipewire/core.c index 48ffaa14..dcf0def6 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -105,8 +105,10 @@ static const struct pw_resource_events resource_events = { static int destroy_resource(void *object, void *data) { struct pw_resource *resource = object; - if (resource && resource != resource->client->core_resource) + if (resource && resource != resource->client->core_resource) { + resource->removed = true; pw_resource_destroy(resource); + } return 0; } diff --git a/src/pipewire/interfaces.h b/src/pipewire/interfaces.h index 3794f702..9217ce9c 100644 --- a/src/pipewire/interfaces.h +++ b/src/pipewire/interfaces.h @@ -117,6 +117,9 @@ struct pw_core_proxy_methods { /** * Start a conversation with the server. This will send * the core info and server types. + * + * All the existing resources for the client (except the core + * resource) will be destroyed. */ void (*hello) (void *object); /** diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 17e8884b..42612f1d 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -435,6 +435,8 @@ struct pw_resource { uint32_t type; /**< type of the client interface */ uint32_t version; /**< version of the client interface */ + bool removed; /**< if the resource was removed */ + struct spa_hook implementation; struct spa_hook_list implementation_list; struct spa_hook_list listener_list; diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index 173eb4fe..f63a973a 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -181,10 +181,12 @@ static void core_event_remove_id(void *data, uint32_t id) struct pw_proxy *proxy; pw_log_debug("remote %p: object remove %u", this, id); - if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) { - pw_proxy_destroy(proxy); - pw_map_remove(&this->objects, id); + if ((proxy = pw_map_lookup(&this->objects, id)) == NULL) { + pw_log_warn("remote %p: asked to remove unknown object id %u", this, id); + return; } + pw_proxy_destroy(proxy); + pw_map_remove(&this->objects, id); } static void diff --git a/src/pipewire/resource.c b/src/pipewire/resource.c index 21959ca3..a3fc5394 100644 --- a/src/pipewire/resource.c +++ b/src/pipewire/resource.c @@ -176,7 +176,7 @@ void pw_resource_destroy(struct pw_resource *resource) pw_map_insert_at(&client->objects, resource->id, NULL); pw_client_events_resource_removed(client, resource); - if (client->core_resource) + if (client->core_resource && !resource->removed) pw_core_resource_remove_id(client->core_resource, resource->id); pw_log_debug("resource %p: free", resource); |