mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-08 12:48:03 +02:00
lib: settings: find the first loaded instance of WpSettings when metadata_name is NULL
This allows changing the metadata name in the configuration file and get all the Lua scripts looking at this new settings metadata without requiring any other code changes. It can be useful in multi-instance setups where we'd like the instances to be isolated and load their own settings instead of relying on each other for that.
This commit is contained in:
parent
219711129e
commit
479523abf9
1 changed files with 8 additions and 4 deletions
|
|
@ -683,8 +683,11 @@ find_settings_func (gpointer g_object, gpointer metadata_name)
|
|||
if (!WP_IS_SETTINGS (g_object))
|
||||
return FALSE;
|
||||
|
||||
return g_str_equal (((WpSettings *) g_object)->metadata_name,
|
||||
(gchar *) metadata_name);
|
||||
if (metadata_name)
|
||||
return g_str_equal (((WpSettings *) g_object)->metadata_name,
|
||||
(gchar *) metadata_name);
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -693,7 +696,8 @@ find_settings_func (gpointer g_object, gpointer metadata_name)
|
|||
* \ingroup wpsettings
|
||||
* \param core the WpCore
|
||||
* \param metadata_name (nullable): the name of the metadata object that the
|
||||
* settings object is associated with; NULL means the default "sm-settings"
|
||||
* settings object is associated with; NULL returns the first settings object
|
||||
* that is found
|
||||
* \returns (transfer full) (nullable): the WpSettings object, or NULL if not
|
||||
* found
|
||||
*/
|
||||
|
|
@ -703,7 +707,7 @@ wp_settings_find (WpCore * core, const gchar * metadata_name)
|
|||
g_return_val_if_fail (WP_IS_CORE (core), NULL);
|
||||
|
||||
GObject *s = wp_core_find_object (core, (GEqualFunc) find_settings_func,
|
||||
metadata_name ? metadata_name : "sm-settings");
|
||||
metadata_name);
|
||||
return s ? WP_SETTINGS (s) : NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue