[vlc-commits] modules: load plugins for choice list on need basis

Rémi Denis-Courmont git at videolan.org
Thu Oct 27 19:00:09 CEST 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct 27 19:59:06 2016 +0300| [081595ac3c7137545eef1580eec8e91513038705] | committer: Rémi Denis-Courmont

modules: load plugins for choice list on need basis

So far, they were loaded at start-up even if there was no request to
enumerate the choices.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=081595ac3c7137545eef1580eec8e91513038705
---

 include/vlc_configuration.h |  1 +
 src/config/core.c           | 12 ++++++++++++
 src/modules/bank.c          | 19 -------------------
 src/modules/cache.c         |  1 +
 src/modules/entry.c         | 17 ++++++++++-------
 5 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/include/vlc_configuration.h b/include/vlc_configuration.h
index 853cf85..30f1f17 100644
--- a/include/vlc_configuration.h
+++ b/include/vlc_configuration.h
@@ -88,6 +88,7 @@ struct module_config_t
     } list;
     const char **list_text;                /* Friendly names for list values */
     const char *list_cb_name;
+    void *owner;
 };
 
 /*****************************************************************************
diff --git a/src/config/core.c b/src/config/core.c
index f1fc516..5b9d7ac 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -355,6 +355,12 @@ ssize_t config_GetIntChoices (vlc_object_t *obj, const char *name,
     size_t count = cfg->list_count;
     if (count == 0)
     {
+        if (module_Map(obj, cfg->owner))
+        {
+            errno = EIO;
+            return -1;
+        }
+
         if (cfg->list.i_cb == NULL)
             return 0;
         return cfg->list.i_cb(obj, name, values, texts);
@@ -465,6 +471,12 @@ ssize_t config_GetPszChoices (vlc_object_t *obj, const char *name,
     size_t count = cfg->list_count;
     if (count == 0)
     {
+        if (module_Map(obj, cfg->owner))
+        {
+            errno = EIO;
+            return -1;
+        }
+
         if (cfg->list.psz_cb == NULL)
             return 0;
         return cfg->list.psz_cb(obj, name, values, texts);
diff --git a/src/modules/bank.c b/src/modules/bank.c
index a4998f6..c8d913c 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -201,25 +201,6 @@ static int AllocatePluginFile (module_bank_t *bank, const char *abspath,
     if (plugin == NULL)
         return -1;
 
-    module_t *module = plugin->module;
-    assert(module != NULL);
-
-    /* For now we force loading if the module's config contains callbacks.
-     * Could be optimized by adding an API call.*/
-    for (size_t i = 0; i < plugin->conf.size; i++)
-         if (!atomic_load_explicit(&plugin->loaded, memory_order_relaxed)
-          && plugin->conf.items[i].list_cb_name != NULL)
-         {
-             /* !unloadable not allowed for plugins with callbacks */
-             vlc_plugin_destroy(plugin);
-
-             assert(bank->mode != CACHE_RESET);
-             plugin = module_InitDynamic(bank->obj, abspath, false);
-             if (unlikely(plugin == NULL))
-                 return -1;
-             break;
-         }
-
     module_StoreBank(plugin);
 
     if (bank->mode != CACHE_IGNORE) /* Add entry to bank */
diff --git a/src/modules/cache.c b/src/modules/cache.c
index cdeb715..e727fa2 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -280,6 +280,7 @@ static int vlc_cache_load_plugin_config(vlc_plugin_t *plugin, block_t *file)
             if (item->i_type == CONFIG_ITEM_BOOL)
                 plugin->conf.booleans++;
         }
+        item->owner = plugin;
     }
 
     return 0;
diff --git a/src/modules/entry.c b/src/modules/entry.c
index f9d6d8c..350fa66 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -142,17 +142,20 @@ static module_config_t *vlc_config_create(vlc_plugin_t *plugin, int type)
     }
 
     memset (tab + confsize, 0, sizeof (tab[confsize]));
+    tab += confsize;
+    tab->owner = plugin;
+
     if (IsConfigIntegerType (type))
     {
-        tab[confsize].max.i = INT64_MAX;
-        tab[confsize].min.i = INT64_MIN;
+        tab->max.i = INT64_MAX;
+        tab->min.i = INT64_MIN;
     }
     else if( IsConfigFloatType (type))
     {
-        tab[confsize].max.f = FLT_MAX;
-        tab[confsize].min.f = FLT_MIN;
+        tab->max.f = FLT_MAX;
+        tab->min.f = FLT_MIN;
     }
-    tab[confsize].i_type = type;
+    tab->i_type = type;
 
     if (CONFIG_ITEM(type))
     {
@@ -160,9 +163,9 @@ static module_config_t *vlc_config_create(vlc_plugin_t *plugin, int type)
         if (type == CONFIG_ITEM_BOOL)
             plugin->conf.booleans++;
     }
-
     plugin->conf.size++;
-    return tab + confsize;
+
+    return tab;
 }
 
 /**



More information about the vlc-commits mailing list