Commit eaa7302d authored by Jean-Philippe André's avatar Jean-Philippe André

Extensions: new script capability "input-listener"

When the input changes (next track, ...), every capable extension
will execute the function "input_changed"
parent 2d46240c
...@@ -40,10 +40,12 @@ static const luaL_Reg p_reg[] = ...@@ -40,10 +40,12 @@ static const luaL_Reg p_reg[] =
*/ */
#define EXT_HAS_MENU (1 << 0) #define EXT_HAS_MENU (1 << 0)
#define EXT_TRIGGER_ONLY (1 << 1) #define EXT_TRIGGER_ONLY (1 << 1)
#define EXT_INPUT_LISTENER (1 << 2)
const char* const ppsz_capabilities[] = { const char* const ppsz_capabilities[] = {
"menu", "menu",
"trigger", "trigger",
"input-listener",
NULL NULL
}; };
...@@ -469,17 +471,24 @@ static int Control( extensions_manager_t *p_mgr, int i_control, va_list args ) ...@@ -469,17 +471,24 @@ static int Control( extensions_manager_t *p_mgr, int i_control, va_list args )
p_ext = ( extension_t* ) va_arg( args, extension_t* ); p_ext = ( extension_t* ) va_arg( args, extension_t* );
input_thread_t *p_input = va_arg( args, struct input_thread_t * ); input_thread_t *p_input = va_arg( args, struct input_thread_t * );
bool ok = LockExtension(p_ext); if( !LockExtension( p_ext ) )
if (!ok)
return VLC_EGENERIC; return VLC_EGENERIC;
// Change input
input_thread_t *old = p_ext->p_sys->p_input; input_thread_t *old = p_ext->p_sys->p_input;
if (old) if( old )
vlc_object_release(old); vlc_object_release( old );
p_ext->p_sys->p_input = p_input ? vlc_object_hold(p_input) : p_input; p_ext->p_sys->p_input = p_input ? vlc_object_hold( p_input )
UnlockExtension(p_ext); : p_input;
// Tell the script the input changed
if( p_ext->p_sys->i_capabilities & EXT_INPUT_LISTENER )
PushCommand( p_ext, CMD_SET_INPUT );
return VLC_SUCCESS; UnlockExtension( p_ext );
break;
} }
default: default:
msg_Err( p_mgr, "Control '%d' not yet implemented in Extension", msg_Err( p_mgr, "Control '%d' not yet implemented in Extension",
i_control ); i_control );
......
...@@ -36,6 +36,7 @@ TYPEDEF_ARRAY( extension_t, array_extension_t ); ...@@ -36,6 +36,7 @@ TYPEDEF_ARRAY( extension_t, array_extension_t );
#define CMD_TRIGGERMENU 3 /* Arg1 = int*, pointing to id to trigger. free */ #define CMD_TRIGGERMENU 3 /* Arg1 = int*, pointing to id to trigger. free */
#define CMD_CLICK 4 /* Arg1 = extension_widget_t* */ #define CMD_CLICK 4 /* Arg1 = extension_widget_t* */
#define CMD_CLOSE 5 #define CMD_CLOSE 5
#define CMD_SET_INPUT 6 /* No arg. Just signal current input changed */
struct extensions_manager_sys_t struct extensions_manager_sys_t
{ {
......
...@@ -342,6 +342,12 @@ static void* Run( void *data ) ...@@ -342,6 +342,12 @@ static void* Run( void *data )
break; break;
} }
case CMD_SET_INPUT:
{
lua_ExecuteFunction( p_mgr, p_ext, "input_changed" );
break;
}
default: default:
{ {
msg_Dbg( p_mgr, "Unknown command in extension command queue: %d", 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