Commit ab515823 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

lua: Factorize timeout detection

parent 67464ac6
......@@ -63,8 +63,6 @@ static const char caps[][20] = {
"playing-listener",
};
#define WATCH_TIMER_PERIOD (10 * CLOCK_FREQ) ///< 10s period for the timer
static int ScanExtensions( extensions_manager_t *p_this );
static int ScanLuaCallback( vlc_object_t *p_this, const char *psz_script,
const struct luabatch_context_t * );
......@@ -948,11 +946,6 @@ int lua_ExecuteFunctionVa( extensions_manager_t *p_mgr, extension_t *p_ext,
i_args ++;
}
// Create watch timer
vlc_mutex_lock( &p_ext->p_sys->command_lock );
vlc_timer_schedule( p_ext->p_sys->timer, false, WATCH_TIMER_PERIOD, 0 );
vlc_mutex_unlock( &p_ext->p_sys->command_lock );
// Start actual call to Lua
if( lua_pcall( L, i_args, 1, 0 ) )
{
......@@ -962,16 +955,6 @@ int lua_ExecuteFunctionVa( extensions_manager_t *p_mgr, extension_t *p_ext,
i_ret = VLC_EGENERIC;
}
// Reset watch timer and timestamp
vlc_mutex_lock( &p_ext->p_sys->command_lock );
if( p_ext->p_sys->p_progress_id != NULL )
{
vlc_dialog_release( p_mgr, p_ext->p_sys->p_progress_id );
p_ext->p_sys->p_progress_id = NULL;
}
vlc_timer_schedule( p_ext->p_sys->timer, false, 0, 0 );
vlc_mutex_unlock( &p_ext->p_sys->command_lock );
i_ret |= lua_DialogFlush( L );
exit:
......@@ -1006,11 +989,6 @@ int lua_ExtensionTriggerMenu( extensions_manager_t *p_mgr,
/* Pass id as unique argument to the function */
lua_pushinteger( L, id );
// Create watch timer
vlc_mutex_lock( &p_ext->p_sys->command_lock );
vlc_timer_schedule( p_ext->p_sys->timer, false, WATCH_TIMER_PERIOD, 0 );
vlc_mutex_unlock( &p_ext->p_sys->command_lock );
if( lua_pcall( L, 1, 1, 0 ) != 0 )
{
msg_Warn( p_mgr, "Error while running script %s, "
......@@ -1019,16 +997,6 @@ int lua_ExtensionTriggerMenu( extensions_manager_t *p_mgr,
i_ret = VLC_EGENERIC;
}
// Reset watch timer and timestamp
vlc_mutex_lock( &p_ext->p_sys->command_lock );
if( p_ext->p_sys->p_progress_id != NULL )
{
vlc_dialog_release( p_mgr, p_ext->p_sys->p_progress_id );
p_ext->p_sys->p_progress_id = NULL;
}
vlc_timer_schedule( p_ext->p_sys->timer, false, 0, 0 );
vlc_mutex_unlock( &p_ext->p_sys->command_lock );
i_ret |= lua_DialogFlush( L );
if( i_ret < VLC_SUCCESS )
{
......
......@@ -28,6 +28,8 @@
#include <vlc_arrays.h>
#include <vlc_dialog.h>
#define WATCH_TIMER_PERIOD (10 * CLOCK_FREQ) ///< 10s period for the timer
/* List of available commands */
typedef enum
{
......
......@@ -332,7 +332,8 @@ static void* Run( void *data )
}
p_ext->p_sys->command = cmd->next;
cmd->next = NULL; /* unlink command (for FreeCommands()) */
// Create watch timer
vlc_timer_schedule( p_ext->p_sys->timer, false, WATCH_TIMER_PERIOD, 0 );
vlc_mutex_unlock( &p_ext->p_sys->command_lock );
/* Run command */
......@@ -423,6 +424,13 @@ static void* Run( void *data )
FreeCommands( cmd );
vlc_mutex_lock( &p_ext->p_sys->command_lock );
// Reset watch timer and timestamp
if( p_ext->p_sys->p_progress_id != NULL )
{
vlc_dialog_release( p_mgr, p_ext->p_sys->p_progress_id );
p_ext->p_sys->p_progress_id = NULL;
}
vlc_timer_schedule( p_ext->p_sys->timer, false, 0, 0 );
}
vlc_mutex_unlock( &p_ext->p_sys->command_lock );
......
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