Commit eeda6528 authored by Srikanth Raju's avatar Srikanth Raju Committed by Jean-Philippe André

Lua: Add new callback playing_changed for playing status changes

Signed-off-by: default avatarJean-Philippe André <jpeg@videolan.org>
parent 31d2afee
......@@ -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 ) \
......
......@@ -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 );
......
......@@ -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
......
......@@ -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",
......
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