[vlc-commits] vout: add restart proxy callback in case the filter's variable is not a command

Victorien Le Couviour--Tuffet git at videolan.org
Sat Jul 1 18:24:52 CEST 2017


vlc | branch: master | Victorien Le Couviour--Tuffet <victorien.lecouviour.tuffet at gmail.com> | Fri Jun 23 15:22:44 2017 +0200| [4d35bc81ac6dc6acc5fceadb8baa8574b848494f] | committer: Thomas Guillem

vout: add restart proxy callback in case the filter's variable is not a command

This allows to remove the brute filter restart HACK from macOS and QT gui.

The idea actually comes from Thomas Guillem.

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

 src/video_output/control.c      |  2 +-
 src/video_output/video_output.c | 35 +++++++++++++++++++++++++----------
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/video_output/control.c b/src/video_output/control.c
index bbdb8948eb..e4cca29d2a 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -172,7 +172,7 @@ void vout_control_PushString(vout_control_t *ctrl, int type, const char *string)
     vout_control_cmd_t cmd;
 
     vout_control_cmd_Init(&cmd, type);
-    cmd.u.string = strdup(string);
+    cmd.u.string = string ? strdup(string) : NULL;
     vout_control_Push(ctrl, &cmd);
 }
 
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index e46859ddd1..41c3d892fe 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -660,6 +660,15 @@ static int FilterProxyCallback(vlc_object_t *p_this, char const *psz_var,
     return 0;
 }
 
+static int FilterRestartCallback(vlc_object_t *p_this, char const *psz_var,
+                                 vlc_value_t oldval, vlc_value_t newval,
+                                 void *p_data)
+{
+    (void) p_this; (void) psz_var; (void) oldval; (void) newval;
+    vout_ControlChangeFilters((vout_thread_t *)p_data, NULL);
+    return 0;
+}
+
 static void ThreadAddFilterCallbacks(vout_thread_t *vout, filter_t *filter)
 {
     /* Duplicate every command variables from the filter, and add a proxy
@@ -673,12 +682,12 @@ static void ThreadAddFilterCallbacks(vout_thread_t *vout, filter_t *filter)
     {
         char *name = *pname;
         int var_type = var_Type(filter, name);
+        assert(var_Type(vout, name) == 0);
+        var_Create(vout, name, var_type | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND);
         if ((var_type & VLC_VAR_ISCOMMAND))
-        {
-            assert(var_Type(vout, name) == 0);
-            var_Create(vout, name, var_type | VLC_VAR_DOINHERIT);
             var_AddCallback(vout, name, FilterProxyCallback, filter);
-        }
+        else
+            var_AddCallback(vout, name, FilterRestartCallback, vout);
         free(name);
     }
     free(names);
@@ -694,12 +703,15 @@ static int ThreadDelFilterCallbacks(filter_t *filter, void *opaque)
     for (char **pname = names; *pname != NULL; pname++)
     {
         char *name = *pname;
-        int var_type = var_Type(filter, name);
-        if ((var_type & VLC_VAR_ISCOMMAND))
-        {
+        int var_type = var_Type(vout, name);
+        assert(var_type & VLC_VAR_ISCOMMAND);
+        int filter_var_type = var_Type(filter, name);
+
+        if (filter_var_type & VLC_VAR_ISCOMMAND)
             var_DelCallback(vout, name, FilterProxyCallback, filter);
-            var_Destroy(vout, name);
-        }
+        else if (filter_var_type)
+            var_DelCallback(vout, name, FilterRestartCallback, vout);
+        var_Destroy(vout, name);
         free(name);
     }
     free(names);
@@ -1651,7 +1663,10 @@ static int ThreadControl(vout_thread_t *vout, vout_control_cmd_t cmd)
         ThreadDisplayOsdTitle(vout, cmd.u.string);
         break;
     case VOUT_CONTROL_CHANGE_FILTERS:
-        ThreadChangeFilters(vout, NULL, cmd.u.string, -1, false);
+        ThreadChangeFilters(vout, NULL,
+                            cmd.u.string != NULL ?
+                            cmd.u.string : vout->p->filter.configuration,
+                            -1, false);
         break;
     case VOUT_CONTROL_CHANGE_INTERLACE:
         ThreadChangeFilters(vout, NULL, vout->p->filter.configuration,



More information about the vlc-commits mailing list