[vlc-commits] Lua: add sockets to extensions (fixes #9495)
Rémi Denis-Courmont
git at videolan.org
Mon Mar 24 18:56:25 CET 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 24 19:54:13 2014 +0200| [fe30f8c0c3580a93d415004d0e56aa6de7cbbb24] | committer: Rémi Denis-Courmont
Lua: add sockets to extensions (fixes #9495)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fe30f8c0c3580a93d415004d0e56aa6de7cbbb24
---
modules/lua/extension.c | 14 +++++++++++++-
modules/lua/extension.h | 2 ++
modules/lua/extension_thread.c | 1 +
share/lua/README.txt | 2 +-
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/modules/lua/extension.c b/modules/lua/extension.c
index f1efb87..ed9ccd9 100644
--- a/modules/lua/extension.c
+++ b/modules/lua/extension.c
@@ -650,6 +650,8 @@ int lua_ExtensionDeactivate( extensions_manager_t *p_mgr, extension_t *p_ext )
if( !p_ext->p_sys->L )
return VLC_SUCCESS;
+ vlclua_fd_interrupt( &p_ext->p_sys->dtable );
+
// Unset and release input objects
if( p_ext->p_sys->p_input )
{
@@ -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 );
/* Clear Lua State */
+ vlclua_fd_cleanup( &p_ext->p_sys->dtable );
lua_close( p_ext->p_sys->L );
p_ext->p_sys->L = NULL;
@@ -824,7 +827,11 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
luaopen_dialog( L, p_ext );
luaopen_input( 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_osd( L );
luaopen_playlist( L );
@@ -859,6 +866,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
{
msg_Warn( p_mgr, "Error while setting the module "
"search path for %s", p_ext->psz_name );
+ vlclua_fd_cleanup( &p_ext->p_sys->dtable );
lua_close( L );
return NULL;
}
@@ -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,
lua_tostring( L, lua_gettop( L ) ) );
+ vlclua_fd_cleanup( &p_ext->p_sys->dtable );
lua_close( L );
return NULL;
}
@@ -1044,7 +1053,10 @@ static int TriggerExtension( extensions_manager_t *p_mgr,
/* Close lua state for trigger-only extensions */
if( p_ext->p_sys->L )
+ {
+ vlclua_fd_cleanup( &p_ext->p_sys->dtable );
lua_close( p_ext->p_sys->L );
+ }
p_ext->p_sys->L = NULL;
return i_ret;
diff --git a/modules/lua/extension.h b/modules/lua/extension.h
index 0577672..69f1705 100644
--- a/modules/lua/extension.h
+++ b/modules/lua/extension.h
@@ -69,6 +69,8 @@ struct extension_sys_t
/* Lua specific */
lua_State *L;
+ vlclua_dtable_t dtable;
+
/* Thread data */
vlc_thread_t thread;
vlc_mutex_t command_lock;
diff --git a/modules/lua/extension_thread.c b/modules/lua/extension_thread.c
index 6cf285e..a643b6a 100644
--- a/modules/lua/extension_thread.c
+++ b/modules/lua/extension_thread.c
@@ -28,6 +28,7 @@
/* I don't want to include lua headers here */
typedef struct lua_State lua_State;
+#include "vlc.h"
#include "extension.h"
#include "assert.h"
diff --git a/share/lua/README.txt b/share/lua/README.txt
index c29cc4a..eb6a8b1 100644
--- a/share/lua/README.txt
+++ b/share/lua/README.txt
@@ -160,7 +160,7 @@ misc.quit(): Quit VLC.
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
More information about the vlc-commits
mailing list