mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-09 02:48:05 +02:00
Merge branch 'deactivate-plugins-before-shutdown' into 'master'
Deactivate all objects and plugins before shutdown See merge request pipewire/wireplumber!833
This commit is contained in:
commit
460b001a6c
2 changed files with 32 additions and 0 deletions
|
|
@ -166,6 +166,13 @@ wp_registry_clear (WpRegistry *self)
|
|||
g_clear_pointer (&self->tmp_globals, g_ptr_array_unref);
|
||||
g_clear_pointer (&self->features, g_ptr_array_unref);
|
||||
|
||||
/* make sure all objects are disabled before clearing the registry */
|
||||
for (guint i = 0; i < self->objects->len; i++) {
|
||||
gpointer o = g_ptr_array_index (self->objects, i);
|
||||
if (WP_IS_OBJECT (o))
|
||||
wp_object_deactivate (WP_OBJECT (o), WP_OBJECT_FEATURES_ALL);
|
||||
}
|
||||
|
||||
/* remove all the registered objects
|
||||
this will normally also destroy the object managers, eventually, since
|
||||
they are normally ref'ed by modules, which are registered objects */
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ struct _WpLuaScriptingPlugin
|
|||
{
|
||||
WpPlugin parent;
|
||||
lua_State *L;
|
||||
GPtrArray *scripts; /* List of all loaded WpLuaScript objects */
|
||||
};
|
||||
|
||||
static int
|
||||
|
|
@ -90,6 +91,7 @@ G_DEFINE_TYPE_WITH_CODE (WpLuaScriptingPlugin, wp_lua_scripting_plugin,
|
|||
static void
|
||||
wp_lua_scripting_plugin_init (WpLuaScriptingPlugin * self)
|
||||
{
|
||||
self->scripts = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -117,6 +119,12 @@ wp_lua_scripting_plugin_disable (WpPlugin * plugin)
|
|||
{
|
||||
WpLuaScriptingPlugin * self = WP_LUA_SCRIPTING_PLUGIN (plugin);
|
||||
|
||||
/* make sure all plugins are disabled before clearing the Lua state */
|
||||
for (guint i = 0; i < self->scripts->len; i++) {
|
||||
WpLuaScript *script = g_ptr_array_index (self->scripts, i);
|
||||
wp_object_deactivate (WP_OBJECT (script), WP_OBJECT_FEATURES_ALL);
|
||||
}
|
||||
|
||||
g_clear_pointer (&self->L, wplua_unref);
|
||||
}
|
||||
|
||||
|
|
@ -187,6 +195,9 @@ wp_lua_scripting_plugin_load (WpComponentLoader * cl, WpCore * core,
|
|||
"arguments", args,
|
||||
NULL);
|
||||
|
||||
/* add the plugin to the list */
|
||||
g_ptr_array_add (self->scripts, g_object_ref (script));
|
||||
|
||||
g_task_return_pointer (task, g_steal_pointer (&script), g_object_unref);
|
||||
}
|
||||
|
||||
|
|
@ -200,11 +211,25 @@ wp_lua_scripting_plugin_load_finish (WpComponentLoader * self,
|
|||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_lua_scripting_plugin_finalize (GObject *object)
|
||||
{
|
||||
WpLuaScriptingPlugin *self = WP_LUA_SCRIPTING_PLUGIN (object);
|
||||
|
||||
g_clear_pointer (&self->scripts, g_ptr_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (wp_lua_scripting_plugin_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
wp_lua_scripting_plugin_class_init (WpLuaScriptingPluginClass * klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
WpPluginClass *plugin_class = (WpPluginClass *) klass;
|
||||
|
||||
object_class->finalize = wp_lua_scripting_plugin_finalize;
|
||||
|
||||
plugin_class->enable = wp_lua_scripting_plugin_enable;
|
||||
plugin_class->disable = wp_lua_scripting_plugin_disable;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue