]> git.sesse.net Git - vlc/blobdiff - src/input/var.c
Clean up input events.
[vlc] / src / input / var.c
index 8218d6ad38dcd12fac555d7ebddf319a7677d39e..c61f3579b7f803d4daed9c59b824b993cc4d6c0a 100644 (file)
@@ -68,6 +68,9 @@ static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
                               vlc_value_t oldval, vlc_value_t newval,
                               void *p_data );
 
+static int IntfEvent( vlc_object_t *p_this, char const *psz_cmd,
+                      vlc_value_t oldval, vlc_value_t newval, void *p_data );
+
 typedef struct
 {
     const char *psz_name;
@@ -225,14 +228,14 @@ void input_ControlVarInit ( input_thread_t *p_input )
 
     if( !p_input->b_preparsing )
     {
-        /* Special "intf-change" variable, it allows intf to set up a callback
-         * to be notified of some changes.
-         *
-         * Add rate-change to inform about rate changin
-         *
-         * stats-change to inform when statistics are computed
-         *
-         * TODO list all changes warn by these callbacks */
+        /* Special "intf-event" variable. */
+        var_Create( p_input, "intf-event", VLC_VAR_INTEGER );
+
+        /* Callback for legacy variables */
+        var_AddCallback( p_input, "intf-event", IntfEvent, NULL );
+
+        /* Legacy variable
+         * TODO remove them when unused */
         static const char *ppsz_event[] = {
             "intf-change",
             "rate-change",
@@ -837,3 +840,21 @@ static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
     return VLC_SUCCESS;
 }
 
+static int IntfEvent( vlc_object_t *p_this, char const *psz_cmd,
+                      vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
+    switch( newval.i_int )
+    {
+    case INPUT_EVENT_RATE:
+        return var_SetBool( p_this, "rate-change", true );
+    case INPUT_EVENT_STATISTICS:
+        return var_SetBool( p_this, "stats-change", true );
+    case INPUT_EVENT_VOUT:
+        return var_SetBool( p_this, "intf-change-vout", true );
+
+    default:
+        return var_SetBool( p_this, "intf-change", true );
+    }
+}
+