Work on cleanup

Add signal handlers for daemon to shut down
Add destroy listeners for modules and do cleanup
Fix some leaks
Simplify port registration in new nodes
Hide some more data structures
Let the node implementation take care of the reuse_buffer signal because
then we can get to the graph nodes to find the destination port.
Destroy modules in core cleanup. Modules should undo everything they
have done.
Activate the link after we negotiated format and buffers.
This commit is contained in:
Wim Taymans 2017-08-22 18:30:10 +02:00
parent 12e2fae8ab
commit c25834a692
31 changed files with 586 additions and 344 deletions

View file

@ -36,6 +36,7 @@ struct impl {
struct pw_properties *properties;
struct spa_hook core_listener;
struct spa_hook module_listener;
struct spa_list node_list;
};
@ -71,8 +72,11 @@ static struct node_info *find_node_info(struct impl *impl, struct pw_node *node)
static void link_data_remove(struct link_data *data)
{
spa_list_remove(&data->l);
spa_hook_remove(&data->link_listener);
if (data->node_info) {
spa_list_remove(&data->l);
spa_hook_remove(&data->link_listener);
data->node_info = NULL;
}
}
static void node_info_free(struct node_info *info)
@ -290,6 +294,27 @@ core_global_removed(void *data, struct pw_global *global)
}
}
static void module_destroy(void *data)
{
struct impl *impl = data;
struct node_info *info, *t;
spa_list_for_each_safe(info, t, &impl->node_list, l)
node_info_free(info);
spa_hook_remove(&impl->core_listener);
spa_hook_remove(&impl->module_listener);
if (impl->properties)
pw_properties_free(impl->properties);
free(impl);
}
const struct pw_module_events module_events = {
PW_VERSION_MODULE_EVENTS,
.destroy = module_destroy,
};
const struct pw_core_events core_events = {
PW_VERSION_CORE_EVENTS,
@ -322,20 +347,11 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
spa_list_init(&impl->node_list);
pw_core_add_listener(core, &impl->core_listener, &core_events, impl);
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
return impl;
}
#if 0
static void module_destroy(struct impl *impl)
{
pw_log_debug("module %p: destroy", impl);
spa_hook_remove(&impl->core_listener);
free(impl);
}
#endif
bool pipewire__module_init(struct pw_module *module, const char *args)
{
return module_init(module, NULL);