mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
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.
This commit is contained in:
parent
a70fd80c2d
commit
a804b71267
3 changed files with 15 additions and 1 deletions
|
|
@ -148,13 +148,25 @@ static const struct pw_resource_events resource_events = {
|
||||||
.destroy = destroy_registry_resource
|
.destroy = destroy_registry_resource
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int destroy_resource(void *object, void *data)
|
||||||
|
{
|
||||||
|
struct pw_resource *resource = object;
|
||||||
|
if (resource && resource != resource->client->core_resource) {
|
||||||
|
resource->removed = true;
|
||||||
|
pw_resource_destroy(resource);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int core_hello(void *object, uint32_t version)
|
static int core_hello(void *object, uint32_t version)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
|
struct pw_client *client = resource->client;
|
||||||
struct pw_core *this = resource->core;
|
struct pw_core *this = resource->core;
|
||||||
|
|
||||||
pw_log_debug("core %p: hello %d from resource %p", this, version, resource);
|
pw_log_debug("core %p: hello %d from resource %p", this, version, resource);
|
||||||
this->info.change_mask = PW_CORE_CHANGE_MASK_ALL;
|
this->info.change_mask = PW_CORE_CHANGE_MASK_ALL;
|
||||||
|
pw_map_for_each(&client->objects, destroy_resource, client);
|
||||||
pw_core_resource_info(resource, &this->info);
|
pw_core_resource_info(resource, &this->info);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -585,6 +585,8 @@ struct pw_resource {
|
||||||
uint32_t type; /**< type of the client interface */
|
uint32_t type; /**< type of the client interface */
|
||||||
uint32_t version; /**< version of the client interface */
|
uint32_t version; /**< version of the client interface */
|
||||||
|
|
||||||
|
unsigned int removed:1; /**< resource was removed from server */
|
||||||
|
|
||||||
struct spa_hook implementation;
|
struct spa_hook implementation;
|
||||||
struct spa_hook_list implementation_list;
|
struct spa_hook_list implementation_list;
|
||||||
struct spa_hook_list listener_list;
|
struct spa_hook_list listener_list;
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ void pw_resource_destroy(struct pw_resource *resource)
|
||||||
pw_map_insert_at(&client->objects, resource->id, NULL);
|
pw_map_insert_at(&client->objects, resource->id, NULL);
|
||||||
pw_client_emit_resource_removed(client, resource);
|
pw_client_emit_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_core_resource_remove_id(client->core_resource, resource->id);
|
||||||
|
|
||||||
pw_log_debug("resource %p: free", resource);
|
pw_log_debug("resource %p: free", resource);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue