fix cleanup

When the node is destroyed, remove it from the node list and mark
the reference to the node gone so that when the resource is cleaned
up we don't try to destroy the node again.
This commit is contained in:
Wim Taymans 2018-09-20 10:13:00 +02:00
parent 3d1acf3032
commit b50482e346
2 changed files with 4 additions and 10 deletions

View file

@ -64,12 +64,8 @@ struct node_data {
static void resource_destroy(void *data) static void resource_destroy(void *data)
{ {
struct node_data *nd = data; struct node_data *nd = data;
spa_list_remove(&nd->link); if (nd->dsp)
spa_hook_remove(&nd->resource_listener);
if (nd->dsp) {
spa_hook_remove(&nd->dsp_listener);
pw_node_destroy(nd->dsp); pw_node_destroy(nd->dsp);
}
} }
static const struct pw_resource_events resource_events = { static const struct pw_resource_events resource_events = {
@ -80,6 +76,7 @@ static const struct pw_resource_events resource_events = {
static void node_destroy(void *data) static void node_destroy(void *data)
{ {
struct node_data *nd = data; struct node_data *nd = data;
spa_list_remove(&nd->link);
nd->dsp = NULL; nd->dsp = NULL;
} }

View file

@ -57,12 +57,8 @@ struct link_data {
static void resource_destroy(void *data) static void resource_destroy(void *data)
{ {
struct link_data *ld = data; struct link_data *ld = data;
spa_list_remove(&ld->l); if (ld->link)
spa_hook_remove(&ld->resource_listener);
if (ld->link) {
spa_hook_remove(&ld->link_listener);
pw_link_destroy(ld->link); pw_link_destroy(ld->link);
}
} }
static const struct pw_resource_events resource_events = { static const struct pw_resource_events resource_events = {
@ -73,6 +69,7 @@ static const struct pw_resource_events resource_events = {
static void link_destroy(void *data) static void link_destroy(void *data)
{ {
struct link_data *ld = data; struct link_data *ld = data;
spa_list_remove(&ld->l);
ld->link = NULL; ld->link = NULL;
} }