Commit fe30f8c0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Lua: add sockets to extensions (fixes #9495)

parent bfe17fd3
...@@ -650,6 +650,8 @@ int lua_ExtensionDeactivate( extensions_manager_t *p_mgr, extension_t *p_ext ) ...@@ -650,6 +650,8 @@ int lua_ExtensionDeactivate( extensions_manager_t *p_mgr, extension_t *p_ext )
if( !p_ext->p_sys->L ) if( !p_ext->p_sys->L )
return VLC_SUCCESS; return VLC_SUCCESS;
vlclua_fd_interrupt( &p_ext->p_sys->dtable );
// Unset and release input objects // Unset and release input objects
if( p_ext->p_sys->p_input ) if( p_ext->p_sys->p_input )
{ {
...@@ -666,6 +668,7 @@ int lua_ExtensionDeactivate( extensions_manager_t *p_mgr, extension_t *p_ext ) ...@@ -666,6 +668,7 @@ int lua_ExtensionDeactivate( extensions_manager_t *p_mgr, extension_t *p_ext )
int i_ret = lua_ExecuteFunction( p_mgr, p_ext, "deactivate", LUA_END ); int i_ret = lua_ExecuteFunction( p_mgr, p_ext, "deactivate", LUA_END );
/* Clear Lua State */ /* Clear Lua State */
vlclua_fd_cleanup( &p_ext->p_sys->dtable );
lua_close( p_ext->p_sys->L ); lua_close( p_ext->p_sys->L );
p_ext->p_sys->L = NULL; p_ext->p_sys->L = NULL;
...@@ -824,7 +827,11 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr, ...@@ -824,7 +827,11 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
luaopen_dialog( L, p_ext ); luaopen_dialog( L, p_ext );
luaopen_input( L ); luaopen_input( L );
luaopen_msg( L ); luaopen_msg( L );
luaopen_net_generic( L ); if( vlclua_fd_init( L, &p_ext->p_sys->dtable ) )
{
lua_close( L );
return NULL;
}
luaopen_object( L ); luaopen_object( L );
luaopen_osd( L ); luaopen_osd( L );
luaopen_playlist( L ); luaopen_playlist( L );
...@@ -859,6 +866,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr, ...@@ -859,6 +866,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
{ {
msg_Warn( p_mgr, "Error while setting the module " msg_Warn( p_mgr, "Error while setting the module "
"search path for %s", p_ext->psz_name ); "search path for %s", p_ext->psz_name );
vlclua_fd_cleanup( &p_ext->p_sys->dtable );
lua_close( L ); lua_close( L );
return NULL; return NULL;
} }
...@@ -868,6 +876,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr, ...@@ -868,6 +876,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
{ {
msg_Warn( p_mgr, "Error loading script %s: %s", p_ext->psz_name, msg_Warn( p_mgr, "Error loading script %s: %s", p_ext->psz_name,
lua_tostring( L, lua_gettop( L ) ) ); lua_tostring( L, lua_gettop( L ) ) );
vlclua_fd_cleanup( &p_ext->p_sys->dtable );
lua_close( L ); lua_close( L );
return NULL; return NULL;
} }
...@@ -1044,7 +1053,10 @@ static int TriggerExtension( extensions_manager_t *p_mgr, ...@@ -1044,7 +1053,10 @@ static int TriggerExtension( extensions_manager_t *p_mgr,
/* Close lua state for trigger-only extensions */ /* Close lua state for trigger-only extensions */
if( p_ext->p_sys->L ) if( p_ext->p_sys->L )
{
vlclua_fd_cleanup( &p_ext->p_sys->dtable );
lua_close( p_ext->p_sys->L ); lua_close( p_ext->p_sys->L );
}
p_ext->p_sys->L = NULL; p_ext->p_sys->L = NULL;
return i_ret; return i_ret;
......
...@@ -69,6 +69,8 @@ struct extension_sys_t ...@@ -69,6 +69,8 @@ struct extension_sys_t
/* Lua specific */ /* Lua specific */
lua_State *L; lua_State *L;
vlclua_dtable_t dtable;
/* Thread data */ /* Thread data */
vlc_thread_t thread; vlc_thread_t thread;
vlc_mutex_t command_lock; vlc_mutex_t command_lock;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
/* I don't want to include lua headers here */ /* I don't want to include lua headers here */
typedef struct lua_State lua_State; typedef struct lua_State lua_State;
#include "vlc.h"
#include "extension.h" #include "extension.h"
#include "assert.h" #include "assert.h"
......
...@@ -160,7 +160,7 @@ misc.quit(): Quit VLC. ...@@ -160,7 +160,7 @@ misc.quit(): Quit VLC.
Net Net
--- ---
---------------------------------------------------------------- ----------------------------------------------------------------
/!\ NB: this namespace is ONLY usable for interfaces. /!\ NB: this namespace is ONLY usable for interfaces and extensions.
--- ---
---------------------------------------------------------------- ----------------------------------------------------------------
net.url_parse( url, [option delimiter] ): Parse URL. Returns a table with net.url_parse( url, [option delimiter] ): Parse URL. Returns a table with
......
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