X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmisc%2Flua%2Flibs%2Fmisc.c;h=09a8e272701b7f9e91fb68c141b15f6c8b938347;hb=16cb266cb6f46c62213d0a5723b21a11110267b9;hp=d9b8afaa0c067eb5f8dcefa0325b495bc42d5486;hpb=ba2e3c57dfe7781d2b32deb277da997bf51e171e;p=vlc diff --git a/modules/misc/lua/libs/misc.c b/modules/misc/lua/libs/misc.c index d9b8afaa0c..09a8e27270 100644 --- a/modules/misc/lua/libs/misc.c +++ b/modules/misc/lua/libs/misc.c @@ -39,6 +39,7 @@ #include #include #include +#include #include /* Low level lua C API */ #include /* Higher level C API */ @@ -105,7 +106,7 @@ static int vlclua_quit( lua_State *L ) vlc_object_t *p_this = vlclua_get_this( L ); /* The rc.c code also stops the playlist ... not sure if this is needed * though. */ - vlc_object_kill( p_this->p_libvlc ); + libvlc_Quit( p_this->p_libvlc ); return 0; } @@ -114,25 +115,31 @@ static int vlclua_quit( lua_State *L ) *****************************************************************************/ static int vlclua_datadir( lua_State *L ) { - lua_pushstring( L, config_GetDataDir() ); + char *psz_data = config_GetDataDir( vlclua_get_this( L ) ); + lua_pushstring( L, psz_data ); + free( psz_data ); return 1; } static int vlclua_userdatadir( lua_State *L ) { - lua_pushstring( L, config_GetUserDataDir() ); + char *dir = config_GetUserDir( VLC_DATA_DIR ); + lua_pushstring( L, dir ); + free( dir ); return 1; } static int vlclua_homedir( lua_State *L ) { - lua_pushstring( L, config_GetHomeDir() ); + char *home = config_GetUserDir( VLC_HOME_DIR ); + lua_pushstring( L, home ); + free( home ); return 1; } static int vlclua_configdir( lua_State *L ) { - char *dir = config_GetUserConfDir(); + char *dir = config_GetUserDir( VLC_CONFIG_DIR ); lua_pushstring( L, dir ); free( dir ); return 1; @@ -140,7 +147,7 @@ static int vlclua_configdir( lua_State *L ) static int vlclua_cachedir( lua_State *L ) { - char *dir = config_GetCacheDir(); + char *dir = config_GetUserDir( VLC_CACHE_DIR ); lua_pushstring( L, dir ); free( dir ); return 1; @@ -153,7 +160,8 @@ static int vlclua_datadir_list( lua_State *L ) char **ppsz_dir = ppsz_dir_list; int i = 1; - if( vlclua_dir_list( psz_dirname, ppsz_dir_list ) != VLC_SUCCESS ) + if( vlclua_dir_list( vlclua_get_this( L ), psz_dirname, ppsz_dir_list ) + != VLC_SUCCESS ) return 0; lua_newtable( L ); for( ; *ppsz_dir; ppsz_dir++ ) @@ -170,28 +178,18 @@ static int vlclua_datadir_list( lua_State *L ) *****************************************************************************/ static int vlclua_lock_and_wait( lua_State *L ) { - vlc_object_t *p_this = vlclua_get_this( L ); - int b_quit; + intf_thread_t *p_intf = (intf_thread_t *)vlclua_get_this( L ); + intf_sys_t *p_sys = p_intf->p_sys; - vlc_object_lock( p_this ); - b_quit = vlc_object_alive( p_this ); - if( b_quit ) - { - vlc_object_wait( p_this ); - b_quit = vlc_object_alive( p_this ); - } - vlc_object_unlock( p_this ); - lua_pushboolean( L, b_quit ); + vlc_mutex_lock( &p_sys->lock ); + mutex_cleanup_push( &p_sys->lock ); + while( !p_sys->exiting ) + vlc_cond_wait( &p_sys->wait, &p_sys->lock ); + vlc_cleanup_pop(); + lua_pushboolean( L, 1 ); return 1; } -static int vlclua_signal( lua_State *L ) -{ - vlc_object_t *p_this = vlclua_get_this( L ); - vlc_object_signal( p_this ); - return 0; -} - static int vlclua_mdate( lua_State *L ) { lua_pushnumber( L, mdate() ); @@ -208,7 +206,16 @@ static int vlclua_mwait( lua_State *L ) static int vlclua_intf_should_die( lua_State *L ) { intf_thread_t *p_intf = (intf_thread_t*)vlclua_get_this( L ); - lua_pushboolean( L, intf_ShouldDie( p_intf ) ); + lua_pushboolean( L, p_intf->p_sys->exiting ); + return 1; +} + +static int vlclua_action_id( lua_State *L ) +{ + vlc_key_t i_key = vlc_GetActionId( luaL_checkstring( L, 1 ) ); + if (i_key == 0) + return 0; + lua_pushnumber( L, i_key ); return 1; } @@ -227,11 +234,12 @@ static const luaL_Reg vlclua_misc_reg[] = { { "cachedir", vlclua_cachedir }, { "datadir_list", vlclua_datadir_list }, + { "action_id", vlclua_action_id }, + { "mdate", vlclua_mdate }, { "mwait", vlclua_mwait }, { "lock_and_wait", vlclua_lock_and_wait }, - { "signal", vlclua_signal }, { "should_die", vlclua_intf_should_die }, { "quit", vlclua_quit },