component-loader: make wp_core_load_component() API asynchronous

This change completely refactors the way components are loaded in wireplumber:
- The module_init() function must return a GObject now. This object is either
a WpPlugin or a WpSiFactory in the current modules.
- When the component loader initializes a module, it automatically registers
the WpPlugin or WpSiFactory with their respective methods. There is no need
to register the WpPlugin or WpSiFactory in the module now.
- The wp_core_load_component() API has been refactored to be asynchronows. This
allows the component loader to automatically activate WpPlugin objects, and
therefore allows the application to directly get the WpPlugin without having
to find it. This simplifies a lot of things.
- The 'ifexists' and 'nofail' component flags now work even if the respective
WpPlugin could not be activated.
- The code that loads components in main.c has also been simplified a lot,
and the option to load dangling components has also been removed.
This commit is contained in:
Julian Bouzas
2023-02-09 13:11:14 -05:00
parent ad940b6efc
commit c61d1e4245
28 changed files with 519 additions and 703 deletions

View File

@@ -201,12 +201,11 @@ wp_file_monitor_api_class_init (WpFileMonitorApiClass * klass)
G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
}
WP_PLUGIN_EXPORT gboolean
WP_PLUGIN_EXPORT GObject *
wireplumber__module_init (WpCore * core, GVariant * args, GError ** error)
{
wp_plugin_register (g_object_new (wp_file_monitor_api_get_type (),
"name", "file-monitor-api",
"core", core,
NULL));
return TRUE;
return G_OBJECT (g_object_new (wp_file_monitor_api_get_type (),
"name", "file-monitor-api",
"core", core,
NULL));
}