[vlc-devel] commit: Lua: Add new callback playing_changed for playing status changes ( Srikanth Raju )
git version control
git at videolan.org
Sun Feb 14 18:32:42 CET 2010
vlc | branch: master | Srikanth Raju <srikiraju at gmail.com> | Mon Feb 8 23:45:08 2010 +0530| [eeda6528dd9bf2fbb7bc5a61bb5744a59e913847] | committer: Jean-Philippe André
Lua: Add new callback playing_changed for playing status changes
Signed-off-by: Jean-Philippe André <jpeg at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eeda6528dd9bf2fbb7bc5a61bb5744a59e913847
---
include/vlc_extensions.h | 8 ++++++++
modules/misc/lua/extension.c | 15 ++++++++++++++-
modules/misc/lua/extension.h | 1 +
modules/misc/lua/extension_thread.c | 21 +++++++++++++++++++++
4 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/include/vlc_extensions.h b/include/vlc_extensions.h
index 7d94524..07c6221 100644
--- a/include/vlc_extensions.h
+++ b/include/vlc_extensions.h
@@ -75,6 +75,7 @@ enum
EXTENSION_TRIGGER, /**< arg1: extension_t* */
EXTENSION_TRIGGER_MENU, /**< arg1: extension_t*, int (uint16_t) */
EXTENSION_SET_INPUT, /**< arg1: extension_t*, arg2 (input_thread_t) */
+ EXTENSION_PLAYING_CHANGED, /**< arg1: extension_t*, arg2 int( playing status ) */
};
/**
@@ -153,6 +154,13 @@ static inline int extension_SetInput( extensions_manager_t *p_mgr,
return extension_Control( p_mgr, EXTENSION_SET_INPUT, p_ext, p_input );
}
+static inline int extension_PlayingChanged( extensions_manager_t *p_mgr,
+ extension_t *p_ext,
+ int state )
+{
+ return extension_Control( p_mgr, EXTENSION_PLAYING_CHANGED, p_ext, state );
+}
+
/** Can this extension only be triggered but not activated?
Not compatible with HasMenu */
#define extension_TriggerOnly( mgr, ext ) \
diff --git a/modules/misc/lua/extension.c b/modules/misc/lua/extension.c
index 90e588e..16c363f 100644
--- a/modules/misc/lua/extension.c
+++ b/modules/misc/lua/extension.c
@@ -43,12 +43,14 @@ static const luaL_Reg p_reg[] =
#define EXT_TRIGGER_ONLY (1 << 1) ///< Hook: trigger. Not activable
#define EXT_INPUT_LISTENER (1 << 2) ///< Hook: input_changed
#define EXT_META_LISTENER (1 << 3) ///< Hook: meta_changed
+#define EXT_PLAYING_LISTENER (1 << 4) ///< Hook: status_changed
const char* const ppsz_capabilities[] = {
"menu",
"trigger",
"input-listener",
"meta-listener",
+ "playing-listener",
NULL
};
@@ -529,7 +531,18 @@ static int Control( extensions_manager_t *p_mgr, int i_control, va_list args )
UnlockExtension( p_ext );
break;
}
-
+ case EXTENSION_PLAYING_CHANGED:
+ {
+ extension_t *p_ext;
+ p_ext = ( extension_t* ) va_arg( args, extension_t* );
+ assert( p_ext->psz_name != NULL );
+ i = ( int ) va_arg( args, int );
+ if( p_ext->p_sys->i_capabilities & EXT_PLAYING_LISTENER )
+ {
+ PushCommand( p_ext, CMD_PLAYING_CHANGED, i );
+ }
+ break;
+ }
default:
msg_Warn( p_mgr, "Control '%d' not yet implemented in Extension",
i_control );
diff --git a/modules/misc/lua/extension.h b/modules/misc/lua/extension.h
index 22cf46d..0f56853 100644
--- a/modules/misc/lua/extension.h
+++ b/modules/misc/lua/extension.h
@@ -39,6 +39,7 @@ TYPEDEF_ARRAY( extension_t, array_extension_t );
#define CMD_SET_INPUT 6 /* No arg. Just signal current input changed */
#define CMD_UPDATE_META 7 /* No arg. Just signal current input item meta
* changed */
+#define CMD_PLAYING_CHANGED 8 /* Arg1 = int*, New playing status */
//Data types
typedef enum
diff --git a/modules/misc/lua/extension_thread.c b/modules/misc/lua/extension_thread.c
index 41faaf5..1df3cf4 100644
--- a/modules/misc/lua/extension_thread.c
+++ b/modules/misc/lua/extension_thread.c
@@ -122,6 +122,7 @@ static void FreeCommands( struct command_t *command )
break;
case CMD_TRIGGERMENU:
+ case CMD_PLAYING_CHANGED:
free( command->data[0] ); // Arg1 is int*, to free
break;
@@ -228,6 +229,19 @@ int __PushCommand( extension_t *p_ext, bool b_unique, int i_command,
cmd->data[0] = pi;
}
break;
+ case CMD_PLAYING_CHANGED:
+ {
+ int *pi = malloc( sizeof( int ) );
+ if( !pi )
+ {
+ free( cmd );
+ vlc_mutex_unlock( &p_ext->p_sys->command_lock );
+ return VLC_ENOMEM;
+ }
+ *pi = va_arg( args, int );
+ cmd->data[0] = pi;
+ }
+ break;
case CMD_CLOSE:
case CMD_SET_INPUT:
case CMD_UPDATE_META:
@@ -362,6 +376,13 @@ static void* Run( void *data )
break;
}
+ case CMD_PLAYING_CHANGED:
+ {
+ lua_ExecuteFunction( p_mgr, p_ext, "playing_changed",
+ LUA_NUM, *((int *)cmd->data[0]), LUA_END );
+ break;
+ }
+
default:
{
msg_Dbg( p_mgr, "Unknown command in extension command queue: %d",
More information about the vlc-devel
mailing list