[vlc-commits] lua: Factorize timeout detection
Hugo Beauzée-Luyssen
git at videolan.org
Thu Mar 30 13:56:31 CEST 2017
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Mar 28 15:54:00 2017 +0200| [ab515823f44e39693d89072be253a6242a578d55] | committer: Hugo Beauzée-Luyssen
lua: Factorize timeout detection
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ab515823f44e39693d89072be253a6242a578d55
---
modules/lua/extension.c | 32 --------------------------------
modules/lua/extension.h | 2 ++
modules/lua/extension_thread.c | 10 +++++++++-
3 files changed, 11 insertions(+), 33 deletions(-)
diff --git a/modules/lua/extension.c b/modules/lua/extension.c
index 6eb4411..c8b335e 100644
--- a/modules/lua/extension.c
+++ b/modules/lua/extension.c
@@ -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 )
{
diff --git a/modules/lua/extension.h b/modules/lua/extension.h
index fc19a25..e9fa0e5 100644
--- a/modules/lua/extension.h
+++ b/modules/lua/extension.h
@@ -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
{
diff --git a/modules/lua/extension_thread.c b/modules/lua/extension_thread.c
index 6cf3ca6..5c18373 100644
--- a/modules/lua/extension_thread.c
+++ b/modules/lua/extension_thread.c
@@ -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 );
More information about the vlc-commits
mailing list