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

@ -34,11 +34,32 @@
#include "spa-monitor.h"
struct data {
struct pw_spa_monitor *monitor;
struct spa_hook module_listener;
};
static void module_destroy(void *data)
{
struct data *d = data;
spa_hook_remove(&d->module_listener);
pw_spa_monitor_destroy(d->monitor);
}
const struct pw_module_events module_events = {
PW_VERSION_MODULE_EVENTS,
.destroy = module_destroy,
};
bool pipewire__module_init(struct pw_module *module, const char *args)
{
const char *dir;
char **argv;
int n_tokens;
struct pw_spa_monitor *monitor;
struct data *data;
if (args == NULL)
goto wrong_arguments;
@ -50,12 +71,18 @@ bool pipewire__module_init(struct pw_module *module, const char *args)
if ((dir = getenv("SPA_PLUGIN_DIR")) == NULL)
dir = PLUGINDIR;
pw_spa_monitor_load(pw_module_get_core(module),
pw_module_get_global(module),
dir, argv[0], argv[1], argv[2]);
monitor = pw_spa_monitor_load(pw_module_get_core(module),
pw_module_get_global(module),
dir, argv[0], argv[1], argv[2],
sizeof(struct data));
data = monitor->user_data;
data->monitor = monitor;
pw_free_strv(argv);
pw_module_add_listener(module, &data->module_listener, &module_events, data);
return true;
not_enough_arguments: