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[] =
*/
#define EXT_HAS_MENU (1 << 0)
#define EXT_TRIGGER_ONLY (1 << 1)
#define EXT_INPUT_LISTENER (1 << 2)
const char* const ppsz_capabilities[] = {
"menu",
"trigger",
"input-listener",
NULL
};
......@@ -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* );
input_thread_t *p_input = va_arg( args, struct input_thread_t * );
bool ok = LockExtension(p_ext);
if (!ok)
if( !LockExtension( p_ext ) )
return VLC_EGENERIC;
// Change input
input_thread_t *old = p_ext->p_sys->p_input;
if (old)
vlc_object_release(old);
p_ext->p_sys->p_input = p_input ? vlc_object_hold(p_input) : p_input;
UnlockExtension(p_ext);
if( old )
vlc_object_release( old );
p_ext->p_sys->p_input = p_input ? vlc_object_hold( p_input )
: 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:
msg_Err( p_mgr, "Control '%d' not yet implemented in Extension",
i_control );
......
......@@ -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_CLICK 4 /* Arg1 = extension_widget_t* */
#define CMD_CLOSE 5
#define CMD_SET_INPUT 6 /* No arg. Just signal current input changed */
struct extensions_manager_sys_t
{
......
......@@ -342,6 +342,12 @@ static void* Run( void *data )
break;
}
case CMD_SET_INPUT:
{
lua_ExecuteFunction( p_mgr, p_ext, "input_changed" );
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