Commit 081595ac authored by Rémi Denis-Courmont's avatar 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.
parent ddf09a29
......@@ -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;
};
/*****************************************************************************
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment