1 /*****************************************************************************
2 * intf.c: Generic lua inteface functions
3 *****************************************************************************
4 * Copyright (C) 2007 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea at videolan tod org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
33 #include <vlc_charset.h>
35 #include <vlc_interface.h>
36 #include <vlc_playlist.h>
41 #include <lua.h> /* Low level lua C API */
42 #include <lauxlib.h> /* Higher level C API */
43 #include <lualib.h> /* Lua libs */
53 /*****************************************************************************
54 * Internal lua<->vlc utils
55 *****************************************************************************/
56 static inline playlist_t *vlclua_get_playlist_internal( lua_State *L )
58 vlc_object_t *p_this = vlclua_get_this( L );
59 return pl_Yield( p_this );
62 static input_thread_t * vlclua_get_input_internal( lua_State *L )
64 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
65 input_thread_t *p_input = p_playlist->p_input;
66 if( p_input ) vlc_object_yield( p_input );
67 vlc_object_release( p_playlist );
71 /* FIXME: This is high level logic. Should be implemented in lua */
72 #define vlclua_var_toggle_or_set(a,b,c) \
73 __vlclua_var_toggle_or_set(a,VLC_OBJECT(b),c)
74 static int __vlclua_var_toggle_or_set( lua_State *L, vlc_object_t *p_obj,
75 const char *psz_name )
78 if( lua_gettop( L ) > 1 ) return vlclua_error( L );
80 if( lua_gettop( L ) == 0 )
81 b_bool = !var_GetBool( p_obj, psz_name );
82 else /* lua_gettop( L ) == 1 */
84 b_bool = luaL_checkboolean( L, -1 )?VLC_TRUE:VLC_FALSE;
88 if( b_bool != var_GetBool( p_obj, psz_name ) )
89 var_SetBool( p_obj, psz_name, b_bool );
91 lua_pushboolean( L, b_bool );
95 /*****************************************************************************
96 * Libvlc TODO: move to vlc.c
97 *****************************************************************************/
98 static int vlclua_get_libvlc( lua_State *L )
100 vlclua_push_vlc_object( L, vlclua_get_this( L )->p_libvlc,
105 /*****************************************************************************
107 *****************************************************************************/
108 static int vlclua_get_input( lua_State *L )
110 input_thread_t *p_input = vlclua_get_input_internal( L );
113 vlclua_push_vlc_object( L, p_input, vlclua_gc_release );
115 else lua_pushnil( L );
119 static int vlclua_input_info( lua_State *L )
121 input_thread_t * p_input = vlclua_get_input_internal( L );
124 if( !p_input ) return vlclua_error( L );
125 vlc_mutex_lock( &input_GetItem(p_input)->lock );
126 i_cat = input_GetItem(p_input)->i_categories;
127 lua_createtable( L, 0, i_cat );
128 for( i = 0; i < i_cat; i++ )
130 info_category_t *p_category = input_GetItem(p_input)->pp_categories[i];
131 int i_infos = p_category->i_infos;
133 lua_pushstring( L, p_category->psz_name );
134 lua_createtable( L, 0, i_infos );
135 for( j = 0; j < i_infos; j++ )
137 info_t *p_info = p_category->pp_infos[j];
138 lua_pushstring( L, p_info->psz_name );
139 lua_pushstring( L, p_info->psz_value );
140 lua_settable( L, -3 );
142 lua_settable( L, -3 );
144 vlc_object_release( p_input );
148 static int vlclua_is_playing( lua_State *L )
150 input_thread_t * p_input = vlclua_get_input_internal( L );
151 lua_pushboolean( L, !!p_input );
155 static int vlclua_get_title( lua_State *L )
157 input_thread_t *p_input = vlclua_get_input_internal( L );
162 lua_pushstring( L, input_GetItem(p_input)->psz_name );
163 vlc_object_release( p_input );
168 /*****************************************************************************
170 *****************************************************************************/
171 static int vlclua_fullscreen( lua_State *L )
173 vout_thread_t *p_vout;
176 input_thread_t * p_input = vlclua_get_input_internal( L );
177 if( !p_input ) return vlclua_error( L );
179 p_vout = vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
180 if( !p_vout ) return vlclua_error( L );
182 i_ret = vlclua_var_toggle_or_set( L, p_vout, "fullscreen" );
183 vlc_object_release( p_vout );
184 vlc_object_release( p_input );
188 static int vlc_osd_icon_from_string( const char *psz_name )
193 const char *psz_name;
195 { { OSD_PAUSE_ICON, "pause" },
196 { OSD_PLAY_ICON, "play" },
197 { OSD_SPEAKER_ICON, "speaker" },
198 { OSD_MUTE_ICON, "mute" },
201 for( i = 0; pp_icons[i].psz_name; i++ )
203 if( !strcmp( psz_name, pp_icons[i].psz_name ) )
204 return pp_icons[i].i_icon;
209 static int vlclua_osd_icon( lua_State *L )
211 const char *psz_icon = luaL_checkstring( L, 1 );
212 int i_icon = vlc_osd_icon_from_string( psz_icon );
213 int i_chan = luaL_optint( L, 2, DEFAULT_CHAN );
215 return luaL_error( L, "\"%s\" is not a valid osd icon.", psz_icon );
218 vlc_object_t *p_this = vlclua_get_this( L );
219 vout_OSDIcon( p_this, i_chan, i_icon );
224 static int vlclua_osd_message( lua_State *L )
226 const char *psz_message = luaL_checkstring( L, 1 );
227 int i_chan = luaL_optint( L, 2, DEFAULT_CHAN );
228 vlc_object_t *p_this = vlclua_get_this( L );
229 vout_OSDMessage( p_this, i_chan, psz_message );
233 static int vlc_osd_slider_type_from_string( const char *psz_name )
238 const char *psz_name;
240 { { OSD_HOR_SLIDER, "horizontal" },
241 { OSD_VERT_SLIDER, "vertical" },
244 for( i = 0; pp_types[i].psz_name; i++ )
246 if( !strcmp( psz_name, pp_types[i].psz_name ) )
247 return pp_types[i].i_type;
252 static int vlclua_osd_slider( lua_State *L )
254 int i_position = luaL_checkint( L, 1 );
255 const char *psz_type = luaL_checkstring( L, 2 );
256 int i_type = vlc_osd_slider_type_from_string( psz_type );
257 int i_chan = luaL_optint( L, 3, DEFAULT_CHAN );
259 return luaL_error( L, "\"%s\" is not a valid slider type.",
263 vlc_object_t *p_this = vlclua_get_this( L );
264 vout_OSDSlider( p_this, i_chan, i_position, i_type );
269 static int vlclua_spu_channel_register( lua_State *L )
272 vlc_object_t *p_this = vlclua_get_this( L );
273 vout_thread_t *p_vout = vlc_object_find( p_this, VLC_OBJECT_VOUT,
276 return luaL_error( L, "Unable to find vout." );
278 spu_Control( p_vout->p_spu, SPU_CHANNEL_REGISTER, &i_chan );
279 vlc_object_release( p_vout );
280 lua_pushinteger( L, i_chan );
284 static int vlclua_spu_channel_clear( lua_State *L )
286 int i_chan = luaL_checkint( L, 1 );
287 vlc_object_t *p_this = vlclua_get_this( L );
288 vout_thread_t *p_vout = vlc_object_find( p_this, VLC_OBJECT_VOUT,
291 return luaL_error( L, "Unable to find vout." );
293 spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR, i_chan );
294 vlc_object_release( p_vout );
298 /*****************************************************************************
300 *****************************************************************************/
301 static int vlclua_get_playlist( lua_State *L )
303 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
306 vlclua_push_vlc_object( L, p_playlist, vlclua_gc_release );
308 else lua_pushnil( L );
312 static int vlclua_playlist_prev( lua_State * L )
314 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
315 playlist_Prev( p_playlist );
316 vlc_object_release( p_playlist );
320 static int vlclua_playlist_next( lua_State * L )
322 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
323 playlist_Next( p_playlist );
324 vlc_object_release( p_playlist );
328 static int vlclua_playlist_play( lua_State * L )
330 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
331 playlist_Play( p_playlist );
332 vlc_object_release( p_playlist );
336 static int vlclua_playlist_stop( lua_State * L )
338 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
339 playlist_Stop( p_playlist );
340 vlc_object_release( p_playlist );
344 static int vlclua_playlist_clear( lua_State * L )
346 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
347 playlist_Stop( p_playlist ); /* Isn't this already implied by Clear? */
348 playlist_Clear( p_playlist, VLC_FALSE );
349 vlc_object_release( p_playlist );
353 static int vlclua_playlist_repeat( lua_State * L )
355 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
356 int i_ret = vlclua_var_toggle_or_set( L, p_playlist, "repeat" );
357 vlc_object_release( p_playlist );
361 static int vlclua_playlist_loop( lua_State * L )
363 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
364 int i_ret = vlclua_var_toggle_or_set( L, p_playlist, "loop" );
365 vlc_object_release( p_playlist );
369 static int vlclua_playlist_random( lua_State * L )
371 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
372 int i_ret = vlclua_var_toggle_or_set( L, p_playlist, "random" );
373 vlc_object_release( p_playlist );
377 static int vlclua_playlist_goto( lua_State * L )
379 /* XXX: logic copied from rc.c ... i'm not sure that it's ok as it
380 * implies knowledge of the playlist internals. */
381 playlist_t *p_playlist;
383 playlist_item_t *p_item, *p_parent;
386 if( lua_gettop( L ) != 1 ) return vlclua_error( L );
387 i_pos = luaL_checkint( L, -1 );
389 if( i_pos <= 0 ) return 0;
391 p_playlist = vlclua_get_playlist_internal( L );
392 /* The playlist stores 2 times the same item: onelevel & category */
393 i_size = p_playlist->items.i_size / 2;
397 vlc_object_release( p_playlist );
401 p_item = p_parent = p_playlist->items.p_elems[i_pos*2-1];
402 while( p_parent->p_parent )
403 p_parent = p_parent->p_parent;
404 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE,
407 vlc_object_release( p_playlist );
408 lua_pushboolean( L, 1 );
412 static int vlclua_playlist_add( lua_State *L )
415 vlc_object_t *p_this = vlclua_get_this( L );
416 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
417 i_count = vlclua_playlist_add_internal( p_this, L, p_playlist,
419 vlc_object_release( p_playlist );
420 lua_pushinteger( L, i_count );
424 static int vlclua_playlist_enqueue( lua_State *L )
427 vlc_object_t *p_this = vlclua_get_this( L );
428 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
429 i_count = vlclua_playlist_add_internal( p_this, L, p_playlist,
431 vlc_object_release( p_playlist );
432 lua_pushinteger( L, i_count );
436 static int vlclua_playlist_get( lua_State *L )
438 /* TODO: make it possible to get the tree playlist */
439 playlist_t *p_playlist = vlclua_get_playlist_internal( L );
440 playlist_item_t *p_root;
442 if( lua_isboolean( L, 1 ) && lua_toboolean( L, 1 ) )
443 p_root = p_playlist->p_ml_onelevel; /* media library */
445 p_root = p_playlist->p_local_onelevel; /* local/normal playlist */
446 lua_createtable( L, p_root->i_children, 0 );
447 for( i = 0; i < p_root->i_children; i++ )
449 playlist_item_t *p_item = p_root->pp_children[i];
450 input_item_t *p_input = p_item->p_input;
451 lua_pushinteger( L, i+1 );
453 lua_pushstring( L, p_input->psz_name );
454 lua_setfield( L, -2, "name" );
455 lua_pushstring( L, p_input->psz_uri );
456 lua_setfield( L, -2, "path" );
457 lua_pushnumber( L, ((double)p_input->i_duration)*1e-6 );
458 lua_setfield( L, -2, "duration" );
459 lua_pushinteger( L, p_input->i_nb_played );
460 lua_setfield( L, -2, "nb_played" );
461 /* TODO: add (optional) info categories, meta, options, es */
462 lua_settable( L, -3 );
464 vlc_object_release( p_playlist );
468 static int vlclua_playlist_sort( lua_State *L )
470 /* allow setting the different sort keys */
474 /* FIXME: split this in 3 different functions? */
475 static int vlclua_playlist_status( lua_State *L )
477 intf_thread_t *p_intf = (intf_thread_t *)vlclua_get_this( L );
478 playlist_t *p_playlist = pl_Yield( p_intf );
481 if( p_playlist->p_input )
484 input_item_GetURI( input_GetItem( p_playlist->p_input ) );
485 lua_pushstring( L, psz_uri );
487 lua_pushnumber( L, config_GetInt( p_intf, "volume" ) );
488 vlc_mutex_lock( &p_playlist->object_lock );
489 switch( p_playlist->status.i_status )
491 case PLAYLIST_STOPPED:
492 lua_pushstring( L, "stopped" );
494 case PLAYLIST_RUNNING:
495 lua_pushstring( L, "running" );
497 case PLAYLIST_PAUSED:
498 lua_pushstring( L, "paused" );
501 lua_pushstring( L, "unknown" );
504 vlc_mutex_unlock( &p_playlist->object_lock );
507 vlc_object_release( p_playlist );
512 static int vlclua_lock_and_wait( lua_State *L )
514 vlc_object_t *p_this = vlclua_get_this( L );
515 int b_quit = vlc_object_lock_and_wait( p_this );
516 lua_pushboolean( L, b_quit );
520 static int vlclua_signal( lua_State *L )
522 vlc_object_t *p_this = vlclua_get_this( L );
523 vlc_object_signal( p_this );
527 static int vlclua_mdate( lua_State *L )
529 lua_pushnumber( L, mdate() );
533 static int vlclua_intf_should_die( lua_State *L )
535 intf_thread_t *p_intf = (intf_thread_t*)vlclua_get_this( L );
536 lua_pushboolean( L, intf_ShouldDie( p_intf ) );
540 static luaL_Reg p_reg[] =
542 { "input_info", vlclua_input_info },
543 { "is_playing", vlclua_is_playing },
544 { "get_title", vlclua_get_title },
546 { "fullscreen", vlclua_fullscreen },
548 { "mdate", vlclua_mdate },
550 { "module_command", vlclua_module_command },
551 { "libvlc_command", vlclua_libvlc_command },
553 { "decode_uri", vlclua_decode_uri },
554 { "resolve_xml_special_chars", vlclua_resolve_xml_special_chars },
556 { "lock_and_wait", vlclua_lock_and_wait },
557 { "signal", vlclua_signal },
559 { "version", vlclua_version },
560 { "should_die", vlclua_intf_should_die },
561 { "quit", vlclua_quit },
566 static luaL_Reg p_reg_object[] =
568 { "input", vlclua_get_input }, /* This is fast */
569 { "playlist", vlclua_get_playlist }, /* This is fast */
570 { "libvlc", vlclua_get_libvlc }, /* This is fast */
572 { "find", vlclua_object_find }, /* This is slow */
573 { "find_name", vlclua_object_find_name }, /* This is slow */
578 static luaL_Reg p_reg_var[] =
580 { "get", vlclua_var_get },
581 { "get_list", vlclua_var_get_list },
582 { "set", vlclua_var_set },
583 { "add_callback", vlclua_add_callback },
584 { "del_callback", vlclua_del_callback },
589 static luaL_Reg p_reg_config[] =
591 { "get", vlclua_config_get },
592 { "set", vlclua_config_set },
597 static luaL_Reg p_reg_msg[] =
599 { "dbg", vlclua_msg_dbg },
600 { "warn", vlclua_msg_warn },
601 { "err", vlclua_msg_err },
602 { "info", vlclua_msg_info },
607 static luaL_Reg p_reg_playlist[] =
609 { "prev", vlclua_playlist_prev },
610 { "next", vlclua_playlist_next },
611 { "play", vlclua_playlist_play },
612 { "stop", vlclua_playlist_stop },
613 { "clear", vlclua_playlist_clear },
614 { "repeat_", vlclua_playlist_repeat },
615 { "loop", vlclua_playlist_loop },
616 { "random", vlclua_playlist_random },
617 { "goto", vlclua_playlist_goto },
618 { "status", vlclua_playlist_status },
619 { "add", vlclua_playlist_add },
620 { "enqueue", vlclua_playlist_enqueue },
621 { "get", vlclua_playlist_get },
626 static luaL_Reg p_reg_volume[] =
628 { "get", vlclua_volume_get },
629 { "set", vlclua_volume_set },
630 { "up", vlclua_volume_up },
631 { "down", vlclua_volume_down },
636 static luaL_Reg p_reg_osd[] =
638 { "icon", vlclua_osd_icon },
639 { "message", vlclua_osd_message },
640 { "slider", vlclua_osd_slider },
641 { "channel_register", vlclua_spu_channel_register },
642 { "channel_clear", vlclua_spu_channel_clear },
647 static luaL_Reg p_reg_net[] =
649 { "url_parse", vlclua_url_parse },
650 { "listen_tcp", vlclua_net_listen_tcp },
651 { "listen_close", vlclua_net_listen_close },
652 { "accept", vlclua_net_accept },
653 { "close", vlclua_net_close },
654 { "send", vlclua_net_send },
655 { "recv", vlclua_net_recv },
656 { "select", vlclua_net_select },
661 static luaL_Reg p_reg_fd[] =
663 /* { "open", vlclua_fd_open },*/
664 { "read", vlclua_fd_read },
665 { "write", vlclua_fd_write },
667 { "new_fd_set", vlclua_fd_set_new },
668 { "fd_clr", vlclua_fd_clr },
669 { "fd_isset", vlclua_fd_isset },
670 { "fd_set", vlclua_fd_set },
671 { "fd_zero", vlclua_fd_zero },
676 static luaL_Reg p_reg_vlm[] =
678 { "new", vlclua_vlm_new },
679 { "delete", vlclua_vlm_delete },
680 { "execute_command", vlclua_vlm_execute_command },
686 static void Run( intf_thread_t *p_intf );
688 static char *FindFile( intf_thread_t *p_intf, const char *psz_name )
690 char *ppsz_dir_list[] = { NULL, NULL, NULL, NULL };
692 vlclua_dir_list( VLC_OBJECT(p_intf), "luaintf", ppsz_dir_list );
693 for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
697 if( asprintf( &psz_filename, "%s"DIR_SEP"%s.lua", *ppsz_dir,
702 fp = fopen( psz_filename, "r" );
708 free( psz_filename );
713 static inline void luaL_register_submodule( lua_State *L, const char *psz_name,
717 luaL_register( L, NULL, l );
718 lua_setfield( L, -2, psz_name );
723 const char *psz_shortcut;
724 const char *psz_name;
727 /* { "rc", "rc" }, */
728 { "luahotkeys", "hotkeys" },
729 /* { "hotkeys", "hotkeys" }, */
730 { "luatelnet", "telnet" },
731 /* { "telnet", "telnet" }, */
734 static vlc_bool_t WordInList( const char *psz_list, const char *psz_word )
736 const char *psz_str = strstr( psz_list, psz_word );
737 int i_len = strlen( psz_word );
740 if( (psz_str == psz_list || *(psz_str-1) == ',' )
741 /* it doesn't start in middle of a word */
742 /* it doest end in middle of a word */
743 && ( psz_str[i_len] == '\0' || psz_str[i_len] == ',' ) )
745 psz_str = strstr( psz_str, psz_word );
750 static const char *GetModuleName( intf_thread_t *p_intf )
753 const char *psz_intf;
754 if( *p_intf->psz_intf == '$' )
755 psz_intf = var_GetString( p_intf, p_intf->psz_intf+1 );
757 psz_intf = p_intf->psz_intf;
758 for( i = 0; pp_shortcuts[i].psz_name; i++ )
760 if( WordInList( psz_intf, pp_shortcuts[i].psz_shortcut ) )
761 return pp_shortcuts[i].psz_name;
764 return config_GetPsz( p_intf, "lua-intf" );
767 int E_(Open_LuaIntf)( vlc_object_t *p_this )
769 intf_thread_t *p_intf = (intf_thread_t*)p_this;
773 const char *psz_name = GetModuleName( p_intf );
774 const char *psz_config;
775 vlc_bool_t b_config_set = VLC_FALSE;
776 if( !psz_name ) psz_name = "dummy";
778 p_intf->p_sys = (intf_sys_t*)malloc( sizeof(intf_sys_t*) );
783 p_sys = p_intf->p_sys;
784 p_sys->psz_filename = FindFile( p_intf, psz_name );
785 if( !p_sys->psz_filename )
787 msg_Err( p_intf, "Couldn't find lua interface script \"%s\".",
791 msg_Dbg( p_intf, "Found lua interface script: %s", p_sys->psz_filename );
796 msg_Err( p_intf, "Could not create new Lua State" );
801 luaL_openlibs( L ); /* FIXME: we don't want to have all the libs */
803 /* register our functions */
804 luaL_register( L, "vlc", p_reg );
805 /* store a pointer to p_intf */
806 lua_pushlightuserdata( L, p_intf );
807 lua_setfield( L, -2, "private" );
808 /* register submodules */
809 luaL_register_submodule( L, "object", p_reg_object );
810 luaL_register_submodule( L, "var", p_reg_var );
811 luaL_register_submodule( L, "config", p_reg_config );
812 luaL_register_submodule( L, "msg", p_reg_msg );
813 luaL_register_submodule( L, "playlist", p_reg_playlist );
814 luaL_register_submodule( L, "volume", p_reg_volume );
815 luaL_register_submodule( L, "osd", p_reg_osd );
816 luaL_register_submodule( L, "net", p_reg_net );
817 luaL_register_submodule( L, "fd", p_reg_fd );
818 luaL_register_submodule( L, "vlm", p_reg_vlm );
823 /* Setup the module search path */
826 char *psz_char = strrchr(p_sys->psz_filename,DIR_SEP_CHAR);
828 /* FIXME: don't use luaL_dostring */
829 if( asprintf( &psz_command,
830 "package.path = \"%s"DIR_SEP"modules"DIR_SEP"?.lua;\"..package.path",
831 p_sys->psz_filename ) < 0 )
833 *psz_char = DIR_SEP_CHAR;
834 if( luaL_dostring( L, psz_command ) )
839 psz_config = config_GetPsz( p_intf, "lua-config" );
840 if( psz_config && *psz_config )
843 if( asprintf( &psz_buffer, "config={%s}", psz_config ) != -1 )
845 printf("%s\n", psz_buffer);
846 if( luaL_dostring( L, psz_buffer ) == 1 )
847 msg_Err( p_intf, "Error while parsing \"lua-config\"." );
849 lua_getglobal( L, "config" );
850 if( lua_istable( L, -1 ) )
852 lua_getfield( L, -1, psz_name );
853 if( lua_istable( L, -1 ) )
855 lua_setglobal( L, "config" );
856 b_config_set = VLC_TRUE;
861 if( b_config_set == VLC_FALSE )
864 lua_setglobal( L, "config" );
869 p_intf->pf_run = Run;
870 p_intf->psz_header = strdup( psz_name ); /* Do I need to clean that up myself in E_(Close_LuaIntf)? */
875 void E_(Close_LuaIntf)( vlc_object_t *p_this )
877 intf_thread_t *p_intf = (intf_thread_t*)p_this;
879 lua_close( p_intf->p_sys->L );
880 free( p_intf->p_sys );
883 static void Run( intf_thread_t *p_intf )
885 lua_State *L = p_intf->p_sys->L;
887 if( luaL_dofile( L, p_intf->p_sys->psz_filename ) )
889 msg_Err( p_intf, "Error loading script %s: %s",
890 p_intf->p_sys->psz_filename,
891 lua_tostring( L, lua_gettop( L ) ) );
893 p_intf->b_die = VLC_TRUE;
896 p_intf->b_die = VLC_TRUE;