component-loader: pass core and cancellable parameters in load()
Regarding the core parameter, the case used to be that WpComponentLoader was a WpPlugin, so it had a reference to the core internally, but since this is no longer a requirement, we need to pass this explicitly
This commit is contained in:
@@ -93,13 +93,13 @@ wp_component_loader_find (WpCore * core, const gchar * type)
|
||||
}
|
||||
|
||||
static void
|
||||
wp_component_loader_load (WpComponentLoader * self, const gchar * component,
|
||||
const gchar * type, WpSpaJson * args, GAsyncReadyCallback callback,
|
||||
gpointer data)
|
||||
wp_component_loader_load (WpComponentLoader * self, WpCore * core,
|
||||
const gchar * component, const gchar * type, WpSpaJson * args,
|
||||
GCancellable * cancellable, GAsyncReadyCallback callback, gpointer data)
|
||||
{
|
||||
g_return_if_fail (WP_IS_COMPONENT_LOADER (self));
|
||||
WP_COMPONENT_LOADER_GET_IFACE (self)->load (self, component, type,
|
||||
args, callback, data);
|
||||
WP_COMPONENT_LOADER_GET_IFACE (self)->load (self, core, component, type,
|
||||
args, cancellable, callback, data);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -129,20 +129,21 @@ on_object_loaded (WpObject *object, GAsyncResult *res, gpointer data)
|
||||
* \param type the type of the component
|
||||
* \param args (transfer none)(nullable): additional arguments for the component,
|
||||
* expected to be a JSON object
|
||||
* \param cancellable (nullable): optional GCancellable
|
||||
* \param callback (scope async): the callback to call when the operation is done
|
||||
* \param data (closure): data to pass to \a callback
|
||||
*/
|
||||
void
|
||||
wp_core_load_component (WpCore * self, const gchar * component,
|
||||
const gchar * type, WpSpaJson * args, GAsyncReadyCallback callback,
|
||||
gpointer data)
|
||||
const gchar * type, WpSpaJson * args, GCancellable * cancellable,
|
||||
GAsyncReadyCallback callback, gpointer data)
|
||||
{
|
||||
g_autoptr (GTask) task = NULL;
|
||||
g_autoptr (WpComponentLoader) c = NULL;
|
||||
g_autoptr (WpComponentLoader) cl = NULL;
|
||||
|
||||
/* Special case for "module" component type */
|
||||
if (g_str_equal (type, "module")) {
|
||||
task = g_task_new (self, NULL, callback, data);
|
||||
task = g_task_new (self, cancellable, callback, data);
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autoptr (GObject) o = NULL;
|
||||
|
||||
@@ -174,16 +175,17 @@ wp_core_load_component (WpCore * self, const gchar * component,
|
||||
}
|
||||
|
||||
/* Otherwise find a component loader for that type and load the component */
|
||||
c = wp_component_loader_find (self, type);
|
||||
if (!c) {
|
||||
task = g_task_new (self, NULL, callback, data);
|
||||
cl = wp_component_loader_find (self, type);
|
||||
if (!cl) {
|
||||
task = g_task_new (self, cancellable, callback, data);
|
||||
g_task_return_new_error (task, WP_DOMAIN_LIBRARY,
|
||||
WP_LIBRARY_ERROR_INVALID_ARGUMENT,
|
||||
"No component loader was found for components of type '%s'", type);
|
||||
return;
|
||||
}
|
||||
|
||||
wp_component_loader_load (c, component, type, args, callback, data);
|
||||
wp_component_loader_load (cl, self, component, type, args, cancellable,
|
||||
callback, data);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -29,9 +29,9 @@ struct _WpComponentLoaderInterface
|
||||
|
||||
gboolean (*supports_type) (WpComponentLoader * self, const gchar * type);
|
||||
|
||||
void (*load) (WpComponentLoader * self, const gchar * component,
|
||||
const gchar * type, WpSpaJson * args, GAsyncReadyCallback callback,
|
||||
gpointer data);
|
||||
void (*load) (WpComponentLoader * self, WpCore * core,
|
||||
const gchar * component, const gchar * type, WpSpaJson * args,
|
||||
GCancellable * cancellable, GAsyncReadyCallback callback, gpointer data);
|
||||
|
||||
/*< private >*/
|
||||
WP_PADDING(6)
|
||||
|
@@ -50,8 +50,8 @@ gchar *wp_core_get_vm_type (WpCore *self);
|
||||
|
||||
WP_API
|
||||
void wp_core_load_component (WpCore * self, const gchar * component,
|
||||
const gchar * type, WpSpaJson * args, GAsyncReadyCallback callback,
|
||||
gpointer data);
|
||||
const gchar * type, WpSpaJson * args, GCancellable * cancellable,
|
||||
GAsyncReadyCallback callback, gpointer data);
|
||||
|
||||
WP_API
|
||||
GObject * wp_core_load_component_finish (WpCore * self, GAsyncResult * res,
|
||||
|
@@ -94,7 +94,7 @@ wp_require_api_transition_execute_step (WpTransition * transition, guint step)
|
||||
"libwireplumber-module-%s", api_name);
|
||||
|
||||
self->pending_plugins++;
|
||||
wp_core_load_component (core, module_name, "module", NULL,
|
||||
wp_core_load_component (core, module_name, "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, self);
|
||||
}
|
||||
}
|
||||
|
@@ -175,13 +175,12 @@ on_script_loaded (WpObject *object, GAsyncResult *res, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
wp_lua_scripting_plugin_load (WpComponentLoader * cl, const gchar * component,
|
||||
const gchar * type, WpSpaJson * args, GAsyncReadyCallback callback,
|
||||
gpointer data)
|
||||
wp_lua_scripting_plugin_load (WpComponentLoader * cl, WpCore * core,
|
||||
const gchar * component, const gchar * type, WpSpaJson * args,
|
||||
GCancellable * cancellable, GAsyncReadyCallback callback, gpointer data)
|
||||
{
|
||||
WpLuaScriptingPlugin * self = WP_LUA_SCRIPTING_PLUGIN (cl);
|
||||
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (cl));
|
||||
g_autoptr (GTask) task = task = g_task_new (core, NULL, callback, data);
|
||||
g_autoptr (GTask) task = task = g_task_new (core, cancellable, callback, data);
|
||||
g_autofree gchar *filepath = NULL;
|
||||
g_autofree gchar *pluginname = NULL;
|
||||
g_autoptr (WpPlugin) script = NULL;
|
||||
|
@@ -186,7 +186,7 @@ load_enable_components (WpInitTransition *self)
|
||||
self->curr_component->name, self->curr_component->type,
|
||||
self->curr_component->priority, self->curr_component->flags);
|
||||
wp_core_load_component (core, self->curr_component->name,
|
||||
self->curr_component->type, NULL,
|
||||
self->curr_component->type, NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, self);
|
||||
return FALSE;
|
||||
}
|
||||
|
@@ -1412,10 +1412,10 @@ main (gint argc, gchar **argv)
|
||||
/* load required API modules */
|
||||
ctl.pending_plugins++;
|
||||
wp_core_load_component (ctl.core, "libwireplumber-module-default-nodes-api",
|
||||
"module", NULL, (GAsyncReadyCallback) on_plugin_loaded, &ctl);
|
||||
"module", NULL, NULL, (GAsyncReadyCallback) on_plugin_loaded, &ctl);
|
||||
ctl.pending_plugins++;
|
||||
wp_core_load_component (ctl.core, "libwireplumber-module-mixer-api",
|
||||
"module", NULL, (GAsyncReadyCallback) on_plugin_loaded, &ctl);
|
||||
"module", NULL, NULL, (GAsyncReadyCallback) on_plugin_loaded, &ctl);
|
||||
|
||||
/* connect */
|
||||
if (!wp_core_connect (ctl.core)) {
|
||||
|
@@ -140,14 +140,14 @@ wp_init_transition_execute_step (WpTransition * transition, guint step)
|
||||
|
||||
case STEP_ACTIVATE_PLUGINS: {
|
||||
wp_core_load_component (core, "libwireplumber-module-lua-scripting",
|
||||
"module", NULL, (GAsyncReadyCallback) on_plugin_loaded, self);
|
||||
"module", NULL, NULL, (GAsyncReadyCallback) on_plugin_loaded, self);
|
||||
wp_core_load_component (core, "libwireplumber-module-standard-event-source",
|
||||
"module", NULL, (GAsyncReadyCallback) on_plugin_loaded, self);
|
||||
"module", NULL, NULL, (GAsyncReadyCallback) on_plugin_loaded, self);
|
||||
break;
|
||||
}
|
||||
|
||||
case STEP_ACTIVATE_SCRIPT: {
|
||||
wp_core_load_component (core, exec_script, "script/lua", exec_args,
|
||||
wp_core_load_component (core, exec_script, "script/lua", exec_args, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, self);
|
||||
break;
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ test_file_monitor_setup (TestFixture * f, gconstpointer user_data)
|
||||
wp_base_test_fixture_setup (&f->base, WP_BASE_TEST_FLAG_DONT_CONNECT);
|
||||
|
||||
wp_core_load_component (f->base.core,
|
||||
"libwireplumber-module-file-monitor-api", "module", NULL,
|
||||
"libwireplumber-module-file-monitor-api", "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
|
||||
|
@@ -45,13 +45,13 @@ test_rd_setup (RdTestFixture *f, gconstpointer data)
|
||||
|
||||
{
|
||||
wp_core_load_component (f->base.core,
|
||||
"libwireplumber-module-reserve-device", "module", NULL,
|
||||
"libwireplumber-module-reserve-device", "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
}
|
||||
{
|
||||
wp_core_load_component (f->base.client_core,
|
||||
"libwireplumber-module-reserve-device", "module", NULL,
|
||||
"libwireplumber-module-reserve-device", "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ test_si_audio_adapter_setup (TestFixture * f, gconstpointer user_data)
|
||||
}
|
||||
{
|
||||
wp_core_load_component (f->base.core,
|
||||
"libwireplumber-module-si-audio-adapter", "module", NULL,
|
||||
"libwireplumber-module-si-audio-adapter", "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
}
|
||||
}
|
||||
|
@@ -40,12 +40,12 @@ test_si_audio_virtual_setup (TestFixture * f, gconstpointer user_data)
|
||||
}
|
||||
{
|
||||
wp_core_load_component (f->base.core,
|
||||
"libwireplumber-module-si-audio-adapter", "module", NULL,
|
||||
"libwireplumber-module-si-audio-adapter", "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
}
|
||||
{
|
||||
wp_core_load_component (f->base.core,
|
||||
"libwireplumber-module-si-audio-virtual", "module", NULL,
|
||||
"libwireplumber-module-si-audio-virtual", "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ test_si_node_setup (TestFixture * f, gconstpointer user_data)
|
||||
}
|
||||
{
|
||||
wp_core_load_component (f->base.core,
|
||||
"libwireplumber-module-si-node", "module", NULL,
|
||||
"libwireplumber-module-si-node", "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
}
|
||||
}
|
||||
|
@@ -95,11 +95,11 @@ test_si_standard_link_setup (TestFixture * f, gconstpointer user_data)
|
||||
}
|
||||
{
|
||||
wp_core_load_component (f->base.core,
|
||||
"libwireplumber-module-si-audio-adapter", "module", NULL,
|
||||
"libwireplumber-module-si-audio-adapter", "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
|
||||
wp_core_load_component (f->base.core,
|
||||
"libwireplumber-module-si-standard-link", "module", NULL,
|
||||
"libwireplumber-module-si-standard-link", "module", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
}
|
||||
|
||||
|
@@ -205,7 +205,7 @@ load_component (ScriptRunnerFixture *f, const gchar *name, const gchar *type)
|
||||
plugin_name = g_strdup (name);
|
||||
}
|
||||
|
||||
wp_core_load_component (f->base.core, component_name, type, NULL,
|
||||
wp_core_load_component (f->base.core, component_name, type, NULL, NULL,
|
||||
(GAsyncReadyCallback) on_plugin_loaded, f);
|
||||
|
||||
if (!g_str_has_prefix (name, "si"))
|
||||
|
Reference in New Issue
Block a user