Commit c972cfd0 authored by Thomas Guillem's avatar Thomas Guillem

libvlc: add an option to disable lua

Playlist lua modules are probed for each opened input. This can take a lot of
time, it can double the time of a local parsing where no lua module are needed.
This time is negligible when playing a file.

Playlist lua probe can take 5ms on desktop (in comparison of 5ms for parsing),
or 50ms on some android devices.

This new option can be used by VLC ports to disable lua when using VLC for
parsing.
parent 2dc1cb57
......@@ -275,8 +275,10 @@ static int ReadDir(stream_t *s, input_item_node_t *node)
*****************************************************************************/
int Import_LuaPlaylist(vlc_object_t *obj)
{
stream_t *s = (stream_t *)obj;
if( lua_Disabled( obj ) )
return VLC_EGENERIC;
stream_t *s = (stream_t *)obj;
if( !vlc_stream_Control( s->p_source, STREAM_IS_DIRECTORY ) )
return VLC_EGENERIC;
......
......@@ -96,6 +96,9 @@ static void inputItemMetaChanged( const vlc_event_t *p_event,
**/
int Open_Extension( vlc_object_t *p_this )
{
if( lua_Disabled( p_this ) )
return VLC_EGENERIC;
msg_Dbg( p_this, "Opening Lua Extension module" );
extensions_manager_t *p_mgr = ( extensions_manager_t* ) p_this;
......
......@@ -201,6 +201,9 @@ static const luaL_Reg p_reg[] = { { NULL, NULL } };
static int Start_LuaIntf( vlc_object_t *p_this, const char *name )
{
if( lua_Disabled( p_this ) )
return VLC_EGENERIC;
intf_thread_t *p_intf = (intf_thread_t*)p_this;
lua_State *L;
......
......@@ -241,6 +241,9 @@ static int fetch_meta( vlc_object_t *p_this, const char * psz_filename,
int ReadMeta( demux_meta_t *p_this )
{
if( lua_Disabled( p_this ) )
return VLC_EGENERIC;
return vlclua_scripts_batch_execute( VLC_OBJECT(p_this), "meta"DIR_SEP"reader",
(void*) &read_meta, NULL );
}
......@@ -252,6 +255,9 @@ int ReadMeta( demux_meta_t *p_this )
int FetchMeta( meta_fetcher_t *p_finder )
{
if( lua_Disabled( p_finder ) )
return VLC_EGENERIC;
luabatch_context_t context = { p_finder->p_item, p_finder->e_scope, validate_scope };
return vlclua_scripts_batch_execute( VLC_OBJECT(p_finder), "meta"DIR_SEP"fetcher",
......@@ -264,6 +270,9 @@ int FetchMeta( meta_fetcher_t *p_finder )
*****************************************************************************/
int FindArt( meta_fetcher_t *p_finder )
{
if( lua_Disabled( p_finder ) )
return VLC_EGENERIC;
luabatch_context_t context = { p_finder->p_item, p_finder->e_scope, validate_scope };
return vlclua_scripts_batch_execute( VLC_OBJECT(p_finder), "meta"DIR_SEP"art",
......
......@@ -154,6 +154,9 @@ static const luaL_Reg p_reg[] = { { NULL, NULL } };
*****************************************************************************/
int Open_LuaSD( vlc_object_t *p_this )
{
if( lua_Disabled( p_this ) )
return VLC_EGENERIC;
services_discovery_t *p_sd = ( services_discovery_t * )p_this;
services_discovery_sys_t *p_sys;
lua_State *L = NULL;
......
......@@ -526,6 +526,9 @@ out:
static int vlc_sd_probe_Open( vlc_object_t *obj )
{
if( lua_Disabled( obj ) )
return VLC_EGENERIC;
vlc_dictionary_t name_d;
char **ppsz_dir_list;
......
......@@ -105,6 +105,12 @@ static inline void lua_Dbg( vlc_object_t * p_this, const char * ppz_fmt, ... )
va_end( ap );
}
static inline bool lua_Disabled( vlc_object_t *p_this )
{
return !var_InheritBool( p_this, "lua" );
}
#define lua_Disabled( x ) lua_Disabled( VLC_OBJECT( x ) )
/*****************************************************************************
* Functions that should be in lua ... but aren't for some obscure reason
*****************************************************************************/
......
......@@ -690,6 +690,9 @@ static const char *const ppsz_prefres[] = {
"$n: Track num<br>$p: Now playing<br>$A: Date<br>$D: Duration<br>" \
"$Z: \"Now playing\" (Fall back on Title - Artist)" )
#define INPUT_LUA_TEXT N_( "Disable lua" )
#define INPUT_LUA_LONGTEXT N_( "Disable all lua plugins" )
// DEPRECATED
#define SUB_CAT_LONGTEXT N_( \
"These options allow you to modify the behavior of the subpictures " \
......@@ -1900,6 +1903,8 @@ vlc_module_begin ()
add_string( "input-title-format", "$Z", INPUT_TITLE_FORMAT_TEXT, INPUT_TITLE_FORMAT_LONGTEXT, false );
add_bool( "lua", true, INPUT_LUA_TEXT, INPUT_LUA_LONGTEXT, true );
/* Decoder options */
set_subcategory( SUBCAT_INPUT_VCODEC )
add_category_hint( N_("Decoders"), CODEC_CAT_LONGTEXT , true )
......
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