]> git.sesse.net Git - vlc/commitdiff
Extensions: new script capability "input-listener"
authorJean-Philippe André <jpeg@videolan.org>
Fri, 29 Jan 2010 11:24:51 +0000 (12:24 +0100)
committerJean-Philippe André <jpeg@videolan.org>
Wed, 3 Feb 2010 16:13:58 +0000 (17:13 +0100)
When the input changes (next track, ...), every capable extension
will execute the function "input_changed"

modules/misc/lua/extension.c
modules/misc/lua/extension.h
modules/misc/lua/extension_thread.c

index 3e5d571e5544408335a3afd31448fb39a5ab8b6c..640993d62415d83957f3beba48b696d2495f2d7c 100644 (file)
@@ -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 );
index 2bd925228dc8c7bec7961d15f44aa8b7c506f6b8..5e9089df7aa331aec76f462c1d7308a8fa70a54b 100644 (file)
@@ -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
 {
index 1d569e93db7b8d1ba3740fd4c1bed31b80cc4582..ecd21452183e64c537cf4b220c6a6c48254a5c50 100644 (file)
@@ -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",