diff --git a/src/daemon/main.c b/src/daemon/main.c index 081036f1a..15e8859ea 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -132,6 +132,7 @@ int main(int argc, char *argv[]) pw_daemon_config_free(config); pw_context_destroy(context); pw_main_loop_destroy(loop); + pw_deinit(); return 0; } diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index 4bbee2a89..e313b32a2 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -409,6 +409,30 @@ void pw_init(int *argc, char **argv[]) pw_log_info("version %s", pw_get_library_version()); } +SPA_EXPORT +void pw_deinit(void) +{ + struct support *support = &global_support; + struct registry *registry = &global_registry; + struct plugin *p; + + support->plugin_dir = NULL; + if (support->categories) + pw_free_strv(support->categories); + support->categories = NULL; + support->support_lib = NULL; + + pw_log_set(NULL); + + spa_list_consume(p, ®istry->plugins, link) { + struct handle *h; + p->ref++; + spa_list_consume(h, &p->handles, link) + unref_handle(h); + unref_plugin(p); + } +} + /** Check if a debug category is enabled * * \param name the name of the category to check diff --git a/src/pipewire/pipewire.h b/src/pipewire/pipewire.h index b3b6bae58..4fa01dd4e 100644 --- a/src/pipewire/pipewire.h +++ b/src/pipewire/pipewire.h @@ -116,6 +116,8 @@ extern "C" { void pw_init(int *argc, char **argv[]); +void pw_deinit(void); + bool pw_debug_is_category_enabled(const char *name);