module-spa: remove the listeners correctly

In the module destroy, remove the module listener and in the
factory_destroy, the factory_listener.
This commit is contained in:
Wim Taymans 2020-11-06 15:37:58 +01:00
parent 42319e32be
commit 6317bc4deb

View file

@ -192,10 +192,10 @@ static void factory_destroy(void *_data)
struct factory_data *data = _data; struct factory_data *data = _data;
struct node_data *nd; struct node_data *nd;
spa_hook_remove(&data->module_listener); spa_hook_remove(&data->factory_listener);
spa_list_consume(nd, &data->node_list, link) spa_list_consume(nd, &data->node_list, link)
pw_impl_node_destroy(nd->node); pw_impl_node_destroy(nd->node);
data->this = NULL;
} }
static const struct pw_impl_factory_events factory_events = { static const struct pw_impl_factory_events factory_events = {
@ -206,6 +206,8 @@ static const struct pw_impl_factory_events factory_events = {
static void module_destroy(void *_data) static void module_destroy(void *_data)
{ {
struct factory_data *data = _data; struct factory_data *data = _data;
spa_hook_remove(&data->module_listener);
if (data->this)
pw_impl_factory_destroy(data->this); pw_impl_factory_destroy(data->this);
} }