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

@ -42,6 +42,7 @@ struct monitor_item {
char *id;
struct spa_list link;
struct pw_node *node;
struct spa_handle *handle;
};
struct impl {
@ -120,10 +121,11 @@ static void add_item(struct pw_spa_monitor *this, struct spa_monitor_item *item)
mitem = calloc(1, sizeof(struct monitor_item));
mitem->id = strdup(id);
mitem->handle = handle;
mitem->node = pw_spa_node_new(impl->core, NULL, impl->parent, name,
false, node_iface, clock_iface, props);
false, node_iface, clock_iface, props, 0);
spa_list_insert(impl->item_list.prev, &mitem->link);
spa_list_append(&impl->item_list, &mitem->link);
}
static struct monitor_item *find_item(struct pw_spa_monitor *this, const char *id)
@ -143,6 +145,8 @@ void destroy_item(struct monitor_item *mitem)
{
pw_node_destroy(mitem->node);
spa_list_remove(&mitem->link);
spa_handle_clear(mitem->handle);
free(mitem->handle);
free(mitem->id);
free(mitem);
}
@ -222,7 +226,9 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
struct pw_global *parent,
const char *dir,
const char *lib,
const char *factory_name, const char *system_name)
const char *factory_name,
const char *system_name,
size_t user_data_size)
{
struct impl *impl;
struct pw_spa_monitor *this;
@ -271,7 +277,7 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
goto interface_failed;
}
impl = calloc(1, sizeof(struct impl));
impl = calloc(1, sizeof(struct impl) + user_data_size);
impl->core = core;
impl->t = t;
impl->parent = parent;
@ -284,6 +290,9 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
this->system_name = strdup(system_name);
this->handle = handle;
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
update_monitor(core, this->system_name);
spa_list_init(&impl->item_list);
@ -321,10 +330,10 @@ void pw_spa_monitor_destroy(struct pw_spa_monitor *monitor)
struct impl *impl = SPA_CONTAINER_OF(monitor, struct impl, this);
struct monitor_item *mitem, *tmp;
pw_log_debug("spa-monitor %p: dispose", impl);
pw_log_debug("spa-monitor %p: destroy", impl);
spa_list_for_each_safe(mitem, tmp, &impl->item_list, link)
destroy_item(mitem);
destroy_item(mitem);
spa_handle_clear(monitor->handle);
free(monitor->handle);