handle cleanup of remote proxies

Destroying a resource informs the client to destroy the proxy.
Destroying an object destroys all the bound resources on it.
This commit is contained in:
Wim Taymans 2016-12-02 17:14:32 +01:00
parent e6f45a7686
commit 5e8a3afe17
8 changed files with 38 additions and 4 deletions

View file

@ -46,6 +46,13 @@ client_dispatch_func (void *object,
return SPA_RESULT_OK;
}
static void
client_unbind_func (void *data)
{
PinosResource *resource = data;
spa_list_remove (&resource->link);
}
static void
client_bind_func (PinosGlobal *global,
PinosClient *client,
@ -61,13 +68,15 @@ client_bind_func (PinosGlobal *global,
id,
global->core->uri.client,
global->object,
NULL);
client_unbind_func);
resource->dispatch_func = client_dispatch_func;
resource->dispatch_data = global;
pinos_log_debug ("client %p: bound to %d", global->object, resource->id);
spa_list_insert (this->resource_list.prev, &resource->link);
m.info = &info;
info.id = resource->id;
info.change_mask = ~0;
@ -102,6 +111,8 @@ pinos_client_new (PinosCore *core,
this->core = core;
this->properties = properties;
spa_list_init (&this->resource_list);
pinos_map_init (&this->objects, 64);
pinos_signal_init (&this->destroy_signal);
@ -149,6 +160,8 @@ destroy_resource (void *object,
void
pinos_client_destroy (PinosClient * client)
{
PinosResource *resource, *tmp;
pinos_log_debug ("client %p: destroy", client);
pinos_signal_emit (&client->destroy_signal, client);
@ -157,6 +170,9 @@ pinos_client_destroy (PinosClient * client)
pinos_global_destroy (client->global);
spa_list_remove (&client->link);
spa_list_for_each_safe (resource, tmp, &client->resource_list, link)
pinos_resource_destroy (resource);
pinos_main_loop_defer (client->core->main_loop,
client,
SPA_RESULT_WAIT_SYNC,