mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
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:
parent
12e2fae8ab
commit
c25834a692
31 changed files with 586 additions and 344 deletions
|
|
@ -73,7 +73,7 @@ struct impl {
|
|||
struct pw_core *core;
|
||||
struct pw_type *t;
|
||||
struct pw_module *module;
|
||||
struct spa_list link;
|
||||
struct spa_hook module_listener;
|
||||
|
||||
struct spa_source *timer;
|
||||
|
||||
|
|
@ -1434,9 +1434,6 @@ static int init_server(struct impl *impl, const char *name, bool promiscuous)
|
|||
for (i = 0; i < CLIENT_NUM; i++)
|
||||
server->synchro_table[i] = JACK_SYNCHRO_INIT;
|
||||
|
||||
if (!init_nodes(impl))
|
||||
return -1;
|
||||
|
||||
s = create_socket();
|
||||
|
||||
if (!init_socket_name(&s->addr, name, promiscuous, 0))
|
||||
|
|
@ -1445,6 +1442,9 @@ static int init_server(struct impl *impl, const char *name, bool promiscuous)
|
|||
if (!add_socket(impl, s))
|
||||
goto error;
|
||||
|
||||
if (!init_nodes(impl))
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
|
@ -1452,6 +1452,26 @@ static int init_server(struct impl *impl, const char *name, bool promiscuous)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void module_destroy(void *data)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
struct link *ld, *t;
|
||||
|
||||
spa_hook_remove(&impl->module_listener);
|
||||
|
||||
spa_list_for_each_safe(ld, t, &impl->link_list, link_link)
|
||||
pw_link_destroy(ld->link);
|
||||
|
||||
if (impl->properties)
|
||||
pw_properties_free(impl->properties);
|
||||
|
||||
free(impl);
|
||||
}
|
||||
|
||||
static const struct pw_module_events module_events = {
|
||||
PW_VERSION_MODULE_EVENTS,
|
||||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
static bool module_init(struct pw_module *module, struct pw_properties *properties)
|
||||
{
|
||||
|
|
@ -1492,6 +1512,8 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
if (init_server(impl, name, promiscuous) < 0)
|
||||
goto error;
|
||||
|
||||
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
|
|
@ -1499,17 +1521,6 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void module_destroy(struct impl *impl)
|
||||
{
|
||||
struct impl *object, *tmp;
|
||||
|
||||
pw_log_debug("module %p: destroy", impl);
|
||||
|
||||
free(impl);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool pipewire__module_init(struct pw_module *module, const char *args)
|
||||
{
|
||||
return module_init(module, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue