Skip to content

Commit

Permalink
modules: load plugins for choice list on need basis
Browse files Browse the repository at this point in the history
So far, they were loaded at start-up even if there was no request to
enumerate the choices.
  • Loading branch information
Rémi Denis-Courmont committed Oct 27, 2016
1 parent ddf09a2 commit 081595a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
1 change: 1 addition & 0 deletions include/vlc_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/*****************************************************************************
Expand Down
12 changes: 12 additions & 0 deletions src/config/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 0 additions & 19 deletions src/modules/bank.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/modules/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 10 additions & 7 deletions src/modules/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,30 @@ 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))
{
plugin->conf.count++;
if (type == CONFIG_ITEM_BOOL)
plugin->conf.booleans++;
}

plugin->conf.size++;
return tab + confsize;

return tab;
}

/**
Expand Down

0 comments on commit 081595a

Please sign in to comment.