remove hooks from objects

Remove the hooks we installed on objects in the destroy/free event
or before calling _destroy. This is not really needed but it is
a nice thing to do because it calls the hook removed callbacks.
This commit is contained in:
Wim Taymans 2020-11-06 15:53:32 +01:00
parent 6317bc4deb
commit 1570e62635
19 changed files with 109 additions and 27 deletions

View file

@ -91,6 +91,7 @@ static void node_destroy(void *data)
struct node_data *nd = data;
pw_log_debug(NAME" %p: destroy %p", nd, nd->adapter);
spa_list_remove(&nd->link);
spa_hook_remove(&nd->adapter_listener);
nd->adapter = NULL;
}

View file

@ -77,6 +77,7 @@ struct node {
static void node_free(void *data)
{
struct node *n = data;
spa_hook_remove(&n->node_listener);
pw_properties_free(n->props);
}

View file

@ -44,6 +44,8 @@ static void proxy_device_destroy(void *_data)
{
struct device_data *data = _data;
spa_hook_remove(&data->device_listener);
spa_hook_remove(&data->device_methods);
spa_hook_remove(&data->proxy_listener);
}
static const struct pw_proxy_events proxy_events = {

View file

@ -104,6 +104,7 @@ static void link_destroy(void *data)
{
struct link_data *ld = data;
spa_list_remove(&ld->l);
spa_hook_remove(&ld->link_listener);
if (ld->global)
spa_hook_remove(&ld->global_listener);
if (ld->resource)

View file

@ -123,6 +123,8 @@ static void global_unbind(void *data)
{
struct resource_data *d = data;
if (d->resource) {
spa_hook_remove(&d->resource_listener);
spa_hook_remove(&d->object_listener);
spa_hook_remove(&d->metadata_listener);
spa_hook_remove(&d->impl_resource_listener);
}

View file

@ -43,7 +43,9 @@ struct object_data {
static void proxy_object_destroy(void *_data)
{
struct object_data *data = _data;
spa_hook_remove(&data->proxy_listener);
spa_hook_remove(&data->object_listener);
spa_hook_remove(&data->object_methods);
}
static const struct pw_proxy_events proxy_events = {

View file

@ -315,6 +315,8 @@ static void client_free(void *data)
pw_log_debug(NAME" %p: free", this);
spa_list_remove(&this->protocol_link);
spa_hook_remove(&this->client_listener);
if (this->source)
pw_loop_destroy_source(client->context->main_loop, this->source);
if (this->connection)
@ -329,6 +331,12 @@ static const struct pw_impl_client_events client_events = {
.busy_changed = client_busy_changed,
};
static void on_server_connection_destroy(void *data)
{
struct client_data *this = data;
spa_hook_remove(&this->conn_listener);
}
static void on_start(void *data, uint32_t version)
{
struct client_data *this = data;
@ -351,6 +359,7 @@ static void on_start(void *data, uint32_t version)
static const struct pw_protocol_native_connection_events server_conn_events = {
PW_VERSION_PROTOCOL_NATIVE_CONNECTION_EVENTS,
.destroy = on_server_connection_destroy,
.start = on_start,
};
@ -772,6 +781,12 @@ error:
goto done;
}
static void on_client_connection_destroy(void *data)
{
struct client *impl = data;
spa_hook_remove(&impl->conn_listener);
}
static void on_need_flush(void *data)
{
struct client *impl = data;
@ -787,6 +802,7 @@ static void on_need_flush(void *data)
static const struct pw_protocol_native_connection_events client_conn_events = {
PW_VERSION_PROTOCOL_NATIVE_CONNECTION_EVENTS,
.destroy = on_client_connection_destroy,
.need_flush = on_need_flush,
};

View file

@ -127,8 +127,12 @@ static void object_destroy(struct object *o)
struct manager *m = o->manager;
spa_list_remove(&o->this.link);
m->this.n_objects--;
if (o->this.proxy)
if (o->this.proxy) {
if (o->info->events)
spa_hook_remove(&o->object_listener);
spa_hook_remove(&o->proxy_listener);
pw_proxy_destroy(o->this.proxy);
}
free(o->this.type);
if (o->this.props)
pw_properties_free(o->this.props);

View file

@ -188,6 +188,7 @@ static void factory_destroy(void *_data)
struct factory_data *data = _data;
struct device_data *nd;
spa_hook_remove(&data->factory_listener);
spa_hook_remove(&data->module_listener);
spa_list_consume(nd, &data->device_list, link)