[vlc-devel] commit: Extensions: new script capability "input-listener" ( Jean-Philippe André )

git version control git at videolan.org
Wed Feb 3 17:21:55 CET 2010


vlc | branch: master | Jean-Philippe André <jpeg at videolan.org> | Fri Jan 29 12:24:51 2010 +0100| [eaa7302d6acc3d2a0f1bad98ee121410e57e6700] | committer: Jean-Philippe André 

Extensions: new script capability "input-listener"

When the input changes (next track, ...), every capable extension
will execute the function "input_changed"

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eaa7302d6acc3d2a0f1bad98ee121410e57e6700
---

 modules/misc/lua/extension.c        |   23 ++++++++++++++++-------
 modules/misc/lua/extension.h        |    1 +
 modules/misc/lua/extension_thread.c |    6 ++++++
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/modules/misc/lua/extension.c b/modules/misc/lua/extension.c
index 3e5d571..640993d 100644
--- a/modules/misc/lua/extension.c
+++ b/modules/misc/lua/extension.c
@@ -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 );
diff --git a/modules/misc/lua/extension.h b/modules/misc/lua/extension.h
index 2bd9252..5e9089d 100644
--- a/modules/misc/lua/extension.h
+++ b/modules/misc/lua/extension.h
@@ -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
 {
diff --git a/modules/misc/lua/extension_thread.c b/modules/misc/lua/extension_thread.c
index 1d569e9..ecd2145 100644
--- a/modules/misc/lua/extension_thread.c
+++ b/modules/misc/lua/extension_thread.c
@@ -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",




More information about the vlc-devel mailing list