[beast: 6/9] BSE: immediately load all plugins and scripts with Bse.server.load_assets()
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 6/9] BSE: immediately load all plugins and scripts with Bse.server.load_assets()
- Date: Thu, 8 Jun 2017 20:23:11 +0000 (UTC)
commit a8ac1e84b9f4cb2791a50e48c1ebf9c71ba06fb9
Author: Tim Janik <timj gnu org>
Date: Fri May 26 00:27:25 2017 +0200
BSE: immediately load all plugins and scripts with Bse.server.load_assets()
Signed-off-by: Tim Janik <timj gnu org>
bse/bseapi.idl | 7 +-
bse/bseserver.cc | 180 +++++++++++++-----------------------------------------
bse/bseserver.hh | 1 +
3 files changed, 48 insertions(+), 140 deletions(-)
---
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 2edde62..4f3b535 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -926,9 +926,10 @@ interface Server : Object {
String get_custom_effect_dir (); ///< Retrieve user specific effects directory.
String get_version (); ///< Retrieve BSE version.
void save_preferences (); ///< Save the bse-preferences property to disk.
- void register_ladspa_plugins(); ///< Register LADSPA (Linux Audio Developer's Simple Plugin
API) plugins.
- void register_core_plugins(); ///< Register core plugins.
- void register_scripts(); ///< Register external scripts.
+ void register_ladspa_plugins(); ///< Register LADSPA (Linux Audio Developer's Simple Plugin
API) plugins asynchronously, DEPRECATED.
+ void register_core_plugins(); ///< Register core plugins asynchronously, DEPRECATED.
+ void register_scripts(); ///< Register external scripts asynchronously, DEPRECATED.
+ void load_assets(); ///< Register plugins and scripts immediately.
bool preferences_locked(); ///< Returns whether the bse-preferences property is currently
locked against modifications or not.
int32 n_scripts(); ///< Return the number of scripts currently running on this
server.
bool can_load (String file_name); ///< Check whether a loader can be found for a wave file.
diff --git a/bse/bseserver.cc b/bse/bseserver.cc
index aec01cd..66b0519 100644
--- a/bse/bseserver.cc
+++ b/bse/bseserver.cc
@@ -1244,89 +1244,65 @@ ServerImpl::save_preferences ()
close (fd);
}
-static gboolean
-register_ladspa_plugins_handler (gpointer data)
+void
+ServerImpl::register_ladspa_plugins ()
{
- BseServer *server = (BseServer*) data;
- SfiRing *lplugins = (SfiRing*) g_object_get_data ((GObject*) server, "ladspa-registration-queue");
- const gchar *error;
-
- if (g_object_get_data ((GObject*) server, "plugin-registration-queue"))
- {
- /* give precedence to core plugins until they're done registering */
- return TRUE;
- }
-
- if (lplugins)
- {
- char *name = (char*) sfi_ring_pop_head (&lplugins);
- g_object_set_data ((GObject*) server, "ladspa-registration-queue", lplugins);
- error = bse_ladspa_plugin_check_load (name);
- bse_server_registration (server, BSE_REGISTER_PLUGIN, name, error);
- g_free (name);
- }
- else
- {
- bse_server_registration (server, BSE_REGISTER_DONE, NULL, NULL);
- return FALSE;
- }
- return TRUE;
+ load_assets();
+ bse_server_registration (as<BseServer*>(), BSE_REGISTER_DONE, NULL, NULL);
}
void
-ServerImpl::register_ladspa_plugins ()
+ServerImpl::register_core_plugins ()
{
- static bool registration_done = false;
- if (registration_done)
- {
- // always honor register_ladspa_plugins() with register_done signal
- bse_server_registration (as<BseServer*>(), BSE_REGISTER_DONE, NULL, NULL);
- return;
- }
- SfiRing *ring = bse_ladspa_plugin_path_list_files ();
- BseServer *server = as<BseServer*>();
- g_object_set_data (server, "ladspa-registration-queue", ring);
- bse_idle_normal (register_ladspa_plugins_handler, server);
- registration_done = true;
+ load_assets();
+ bse_server_registration (as<BseServer*>(), BSE_REGISTER_DONE, NULL, NULL);
}
-static gboolean
-register_core_plugins_handler (gpointer data)
+void
+ServerImpl::register_scripts ()
{
- BseServer *server = (BseServer*) data;
- SfiRing *plugins = (SfiRing*) g_object_get_data ((GObject*) server, "plugin-registration-queue");
- const gchar *error;
+ load_assets();
+ bse_server_registration (as<BseServer*>(), BSE_REGISTER_DONE, NULL, NULL);
+}
- if (plugins)
+void
+ServerImpl::load_assets ()
+{
+ static bool done_once = false;
+ return_unless (!done_once);
+ done_once = true;
+ SfiRing *ring;
+ // load Bse drivers & plugins
+ ring = bse_plugin_path_list_files (true, true);
+ while (ring)
{
- char *name = (char*) sfi_ring_pop_head (&plugins);
- g_object_set_data ((GObject*) server, "plugin-registration-queue", plugins);
- error = bse_plugin_check_load (name);
- bse_server_registration (server, BSE_REGISTER_PLUGIN, name, error);
+ gchar *name = (char*) sfi_ring_pop_head (&ring);
+ const char *error = bse_plugin_check_load (name);
+ if (error)
+ printerr ("%s: Bse plugin registration failed: %s\n", name, error);
g_free (name);
}
- else
+ // load Bse scripts
+ ring = bse_script_path_list_files ();
+ while (ring)
{
- bse_server_registration (server, BSE_REGISTER_DONE, NULL, NULL);
- return FALSE;
+ gchar *script = (char*) sfi_ring_pop_head (&ring);
+ BseJanitor *janitor = NULL;
+ Bse::Error error = bse_script_file_register (script, &janitor);
+ if (!janitor)
+ printerr ("%s: Bse script registration failed: %s\n", script, bse_error_blurb (error));
+ g_free (script);
}
- return TRUE;
-}
-
-void
-ServerImpl::register_core_plugins ()
-{
- static gboolean registration_done = false;
- BseServer *server = as<BseServer*>();
- if (registration_done)
+ // load LADSPA plugins
+ ring = bse_ladspa_plugin_path_list_files ();
+ while (ring)
{
- bse_server_registration (server, BSE_REGISTER_DONE, NULL, NULL);
- return;
+ char *name = (char*) sfi_ring_pop_head (&ring);
+ const char *error = bse_ladspa_plugin_check_load (name);
+ if (error)
+ printerr ("%s: Bse LADSPA plugin registration failed: %s\n", name, error);
+ g_free (name);
}
- SfiRing *ring = bse_plugin_path_list_files (!bse_main_args->load_drivers_early, TRUE);
- g_object_set_data (server, "plugin-registration-queue", ring);
- bse_idle_normal (register_core_plugins_handler, server);
- registration_done = true;
}
void
@@ -1336,76 +1312,6 @@ ServerImpl::start_recording (const String &wave_file, double n_seconds)
bse_server_start_recording (server, wave_file.c_str(), n_seconds);
}
-struct ScriptRegistration
-{
- gchar *script;
- Bse::Error (*register_func) (const gchar *script, BseJanitor **janitor_p);
- ScriptRegistration *next;
-};
-
-static gboolean register_scripts_handler (gpointer data);
-
-static void
-script_janitor_closed (BseJanitor *janitor,
- BseServer *server)
-{
- bse_server_registration (server, BSE_REGISTER_SCRIPT, janitor->script_name, NULL);
- bse_idle_normal (register_scripts_handler, server);
-}
-
-static gboolean
-register_scripts_handler (gpointer data)
-{
- BseServer *server = (BseServer*) data;
- ScriptRegistration *scr = (ScriptRegistration*) g_object_get_data ((GObject*) server,
"script-registration-queue");
- BseJanitor *janitor = NULL;
- Bse::Error error;
-
- if (!scr)
- {
- bse_server_registration (server, BSE_REGISTER_DONE, NULL, NULL);
- return FALSE;
- }
- g_object_set_data ((GObject*) server, "script-registration-queue", scr->next);
-
- error = scr->register_func (scr->script, &janitor);
- if (!janitor)
- bse_server_registration (server, BSE_REGISTER_SCRIPT, scr->script, bse_error_blurb (error));
- else
- g_object_connect (janitor, "signal::shutdown", script_janitor_closed, server, NULL);
- g_free (scr->script);
- g_free (scr);
- return !janitor;
-}
-
-void
-ServerImpl::register_scripts ()
-{
- static gboolean registration_done = false;
- BseServer *server = as<BseServer*>();
-
- if (registration_done)
- {
- bse_server_registration (server, BSE_REGISTER_DONE, NULL, NULL);
- return;
- }
- registration_done = true;
-
- SfiRing *ring = bse_script_path_list_files ();
- ScriptRegistration *scr_list = NULL;
- while (ring)
- {
- ScriptRegistration *scr = g_new0 (ScriptRegistration, 1);
- scr->script = (char*) sfi_ring_pop_head (&ring);
- scr->register_func = bse_script_file_register;
- scr->next = scr_list;
- scr_list = scr;
- }
-
- g_object_set_data (server, "script-registration-queue", scr_list);
- bse_idle_normal (register_scripts_handler, server);
-}
-
bool
ServerImpl::preferences_locked ()
{
diff --git a/bse/bseserver.hh b/bse/bseserver.hh
index 7297b7d..92b831a 100644
--- a/bse/bseserver.hh
+++ b/bse/bseserver.hh
@@ -119,6 +119,7 @@ public:
virtual void register_core_plugins () override;
virtual void start_recording (const String &wave_file, double n_seconds) override;
virtual void register_scripts () override;
+ virtual void load_assets () override;
virtual bool preferences_locked () override;
virtual int n_scripts () override;
virtual bool can_load (const String &file_name) override;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]