[vlc-commits] vout: simplify parameter change functions

Rémi Denis-Courmont git at videolan.org
Sun Jan 27 22:10:21 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jan 27 23:07:47 2019 +0200| [82bed6f09c3b357ff7390656637f39988138c11c] | committer: Rémi Denis-Courmont

vout: simplify parameter change functions

... leveraging the removal of callbacks from previous changeset.

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

 src/video_output/video_output.c  | 90 +++++++++++++++++-----------------------
 src/video_output/vout_internal.h | 25 ++++++-----
 src/video_output/vout_intf.c     | 32 +++++++-------
 src/video_output/window.c        |  2 +-
 4 files changed, 66 insertions(+), 83 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 1a8829efdb..d154b53a95 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -196,20 +196,15 @@ static void vout_SizeWindow(vout_thread_t *vout, unsigned *restrict width,
                             &sys->display_cfg);
 }
 
-static void vout_ControlUpdateWindowSize(vout_thread_t *vout)
+static void vout_UpdateWindowSize(vout_thread_t *vout)
 {
-    vout_window_t *window;
+    unsigned width, height;
 
     vlc_mutex_assert(&vout->p->window_lock);
-    window = vout->p->display_cfg.window;
 
-    if (likely(window != NULL)) {
-        unsigned width, height;
-
-        vout_SizeWindow(vout, &width, &height);
-        msg_Dbg(window, "requested size: %ux%u", width, height);
-        vout_window_SetSize(window, width, height);
-    }
+    vout_SizeWindow(vout, &width, &height);
+    msg_Dbg(vout, "requested window size: %ux%u", width, height);
+    vout_window_SetSize(vout->p->display_cfg.window, width, height);
 }
 
 /* */
@@ -351,45 +346,33 @@ int vout_GetSnapshot(vout_thread_t *vout,
 }
 
 /* vout_Control* are usable by anyone at anytime */
-void vout_ControlChangeFullscreen(vout_thread_t *vout, const char *id)
+void vout_ChangeFullscreen(vout_thread_t *vout, const char *id)
 {
-    vout_window_t *window;
-
     vlc_mutex_lock(&vout->p->window_lock);
-    window = vout->p->display_cfg.window;
-    /* Window is NULL if the output was already closed by its owner. */
-    if (window != NULL)
-        vout_window_SetFullScreen(window, id);
+    vout_window_SetFullScreen(vout->p->display_cfg.window, id);
     vlc_mutex_unlock(&vout->p->window_lock);
 }
 
-void vout_ControlChangeWindowed(vout_thread_t *vout)
+void vout_ChangeWindowed(vout_thread_t *vout)
 {
-    vout_window_t *window;
-
     vlc_mutex_lock(&vout->p->window_lock);
-    window = vout->p->display_cfg.window;
-    if (window != NULL)
-        vout_window_UnsetFullScreen(window);
+    vout_window_UnsetFullScreen(vout->p->display_cfg.window);
     /* Attempt to reset the intended window size */
-    vout_ControlUpdateWindowSize(vout);
+    vout_UpdateWindowSize(vout);
     vlc_mutex_unlock(&vout->p->window_lock);
 }
 
-void vout_ControlChangeWindowState(vout_thread_t *vout, unsigned st)
+void vout_ChangeWindowState(vout_thread_t *vout, unsigned st)
 {
-    vout_window_t *window;
-
     vlc_mutex_lock(&vout->p->window_lock);
-    window = vout->p->display_cfg.window;
-    if (window != NULL)
-        vout_window_SetState(window, st);
+    vout_window_SetState(vout->p->display_cfg.window, st);
     vlc_mutex_unlock(&vout->p->window_lock);
 }
 
-void vout_ControlChangeDisplaySize(vout_thread_t *vout,
-                                   unsigned width, unsigned height)
+void vout_ChangeDisplaySize(vout_thread_t *vout,
+                            unsigned width, unsigned height)
 {
+    /* DO NOT call this outside the vout window callbacks */
     vout_control_cmd_t cmd;
 
     vout_control_cmd_Init(&cmd, VOUT_CONTROL_DISPLAY_SIZE);
@@ -400,7 +383,7 @@ void vout_ControlChangeDisplaySize(vout_thread_t *vout,
     vout_control_Push(&vout->p->control, &cmd);
 }
 
-void vout_ControlChangeDisplayFilled(vout_thread_t *vout, bool is_filled)
+void vout_ChangeDisplayFilled(vout_thread_t *vout, bool is_filled)
 {
     vout_thread_sys_t *sys = vout->p;
 
@@ -413,7 +396,7 @@ void vout_ControlChangeDisplayFilled(vout_thread_t *vout, bool is_filled)
                           is_filled);
 }
 
-void vout_ControlChangeZoom(vout_thread_t *vout, unsigned num, unsigned den)
+void vout_ChangeZoom(vout_thread_t *vout, unsigned num, unsigned den)
 {
     vout_thread_sys_t *sys = vout->p;
 
@@ -436,15 +419,15 @@ void vout_ControlChangeZoom(vout_thread_t *vout, unsigned num, unsigned den)
     sys->display_cfg.zoom.num = num;
     sys->display_cfg.zoom.den = den;
 
-    vout_ControlUpdateWindowSize(vout);
+    vout_UpdateWindowSize(vout);
     vlc_mutex_unlock(&sys->window_lock);
 
     vout_control_PushPair(&vout->p->control, VOUT_CONTROL_ZOOM,
                           num, den);
 }
 
-void vout_ControlChangeSampleAspectRatio(vout_thread_t *vout,
-                                         unsigned num, unsigned den)
+void vout_ChangeSampleAspectRatio(vout_thread_t *vout,
+                                  unsigned num, unsigned den)
 {
     vout_thread_sys_t *sys = vout->p;
 
@@ -452,15 +435,14 @@ void vout_ControlChangeSampleAspectRatio(vout_thread_t *vout,
     sys->source.dar.num = num;
     sys->source.dar.den = den;
 
-    vout_ControlUpdateWindowSize(vout);
+    vout_UpdateWindowSize(vout);
     vlc_mutex_unlock(&sys->window_lock);
 
     vout_control_PushPair(&vout->p->control, VOUT_CONTROL_ASPECT_RATIO,
                           num, den);
 }
 
-void vout_ControlChangeCropRatio(vout_thread_t *vout,
-                                 unsigned num, unsigned den)
+void vout_ChangeCropRatio(vout_thread_t *vout, unsigned num, unsigned den)
 {
     vout_thread_sys_t *sys = vout->p;
 
@@ -472,15 +454,15 @@ void vout_ControlChangeCropRatio(vout_thread_t *vout,
     } else
         sys->source.crop.mode = VOUT_CROP_NONE;
 
-    vout_ControlUpdateWindowSize(vout);
+    vout_UpdateWindowSize(vout);
     vlc_mutex_unlock(&sys->window_lock);
 
     vout_control_PushPair(&vout->p->control, VOUT_CONTROL_CROP_RATIO,
                           num, den);
 }
 
-void vout_ControlChangeCropWindow(vout_thread_t *vout,
-                                  int x, int y, int width, int height)
+void vout_ChangeCropWindow(vout_thread_t *vout,
+                           int x, int y, int width, int height)
 {
     vout_thread_sys_t *sys = vout->p;
     vout_control_cmd_t cmd;
@@ -501,7 +483,7 @@ void vout_ControlChangeCropWindow(vout_thread_t *vout,
     sys->source.crop.window.width = width;
     sys->source.crop.window.height = height;
 
-    vout_ControlUpdateWindowSize(vout);
+    vout_UpdateWindowSize(vout);
     vlc_mutex_unlock(&sys->window_lock);
 
     vout_control_cmd_Init(&cmd, VOUT_CONTROL_CROP_WINDOW);
@@ -512,8 +494,8 @@ void vout_ControlChangeCropWindow(vout_thread_t *vout,
     vout_control_Push(&vout->p->control, &cmd);
 }
 
-void vout_ControlChangeCropBorder(vout_thread_t *vout,
-                                  int left, int top, int right, int bottom)
+void vout_ChangeCropBorder(vout_thread_t *vout,
+                           int left, int top, int right, int bottom)
 {
     vout_thread_sys_t *sys = vout->p;
     vout_control_cmd_t cmd;
@@ -534,7 +516,7 @@ void vout_ControlChangeCropBorder(vout_thread_t *vout,
     sys->source.crop.border.top = top;
     sys->source.crop.border.bottom = bottom;
 
-    vout_ControlUpdateWindowSize(vout);
+    vout_UpdateWindowSize(vout);
     vlc_mutex_unlock(&sys->window_lock);
 
     vout_control_cmd_Init(&cmd, VOUT_CONTROL_CROP_BORDER);
@@ -567,16 +549,18 @@ void vout_ControlChangeSubFilters(vout_thread_t *vout, const char *filters)
     vlc_mutex_unlock(&vout->p->spu_lock);
 }
 
-void vout_ControlChangeSubMargin(vout_thread_t *vout, int margin)
+void vout_ChangeSubMargin(vout_thread_t *vout, int margin)
 {
+    if (unlikely(vout->p->spu == NULL))
+        return;
+
     vlc_mutex_lock(&vout->p->spu_lock);
-    if (likely(vout->p->spu != NULL))
-        spu_ChangeMargin(vout->p->spu, margin);
+    spu_ChangeMargin(vout->p->spu, margin);
     vlc_mutex_unlock(&vout->p->spu_lock);
 }
 
-void vout_ControlChangeViewpoint(vout_thread_t *vout,
-                                 const vlc_viewpoint_t *p_viewpoint)
+void vout_ChangeViewpoint(vout_thread_t *vout,
+                          const vlc_viewpoint_t *p_viewpoint)
 {
     vout_thread_sys_t *sys = vout->p;
     vout_control_cmd_t cmd;
@@ -1815,7 +1799,7 @@ vout_thread_t *vout_Request(vlc_object_t *object,
         sys->dpb_size = cfg->dpb_size;
 
         vlc_mutex_lock(&vout->p->window_lock);
-        vout_ControlUpdateWindowSize(vout);
+        vout_UpdateWindowSize(vout);
         vlc_mutex_unlock(&vout->p->window_lock);
     } else {
         vout = VoutCreate(object, cfg);
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index e7143dfc62..c4c1ffcd71 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -211,22 +211,21 @@ void vout_Stop(vout_thread_t *);
 void vout_Close( vout_thread_t *p_vout );
 
 /* TODO to move them to vlc_vout.h */
-void vout_ControlChangeFullscreen(vout_thread_t *, const char *id);
-void vout_ControlChangeWindowed(vout_thread_t *);
-void vout_ControlChangeWindowState(vout_thread_t *, unsigned state);
-void vout_ControlChangeDisplaySize(vout_thread_t *,
-                                   unsigned width, unsigned height);
-void vout_ControlChangeDisplayFilled(vout_thread_t *, bool is_filled);
-void vout_ControlChangeZoom(vout_thread_t *, unsigned num, unsigned den);
-void vout_ControlChangeSampleAspectRatio(vout_thread_t *, unsigned num, unsigned den);
-void vout_ControlChangeCropRatio(vout_thread_t *, unsigned num, unsigned den);
-void vout_ControlChangeCropWindow(vout_thread_t *, int x, int y, int width, int height);
-void vout_ControlChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom);
+void vout_ChangeFullscreen(vout_thread_t *, const char *id);
+void vout_ChangeWindowed(vout_thread_t *);
+void vout_ChangeWindowState(vout_thread_t *, unsigned state);
+void vout_ChangeDisplaySize(vout_thread_t *, unsigned width, unsigned height);
+void vout_ChangeDisplayFilled(vout_thread_t *, bool is_filled);
+void vout_ChangeZoom(vout_thread_t *, unsigned num, unsigned den);
+void vout_ChangeSampleAspectRatio(vout_thread_t *, unsigned num, unsigned den);
+void vout_ChangeCropRatio(vout_thread_t *, unsigned num, unsigned den);
+void vout_ChangeCropWindow(vout_thread_t *, int x, int y, int width, int height);
+void vout_ChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom);
 void vout_ControlChangeFilters(vout_thread_t *, const char *);
 void vout_ControlChangeSubSources(vout_thread_t *, const char *);
 void vout_ControlChangeSubFilters(vout_thread_t *, const char *);
-void vout_ControlChangeSubMargin(vout_thread_t *, int);
-void vout_ControlChangeViewpoint( vout_thread_t *, const vlc_viewpoint_t *);
+void vout_ChangeSubMargin(vout_thread_t *, int);
+void vout_ChangeViewpoint( vout_thread_t *, const vlc_viewpoint_t *);
 
 /* */
 void vout_IntfInit( vout_thread_t * );
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 7008cf69bd..bb9d335241 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -456,15 +456,15 @@ static int CropCallback( vlc_object_t *object, char const *cmd,
     unsigned left, top, right, bottom;
 
     if (sscanf(newval.psz_string, "%u:%u", &num, &den) == 2) {
-        vout_ControlChangeCropRatio(vout, num, den);
+        vout_ChangeCropRatio(vout, num, den);
     } else if (sscanf(newval.psz_string, "%ux%u+%u+%u",
                       &width, &height, &x, &y) == 4) {
-        vout_ControlChangeCropWindow(vout, x, y, width, height);
+        vout_ChangeCropWindow(vout, x, y, width, height);
     } else if (sscanf(newval.psz_string, "%u+%u+%u+%u",
                     &left, &top, &right, &bottom) == 4) {
-        vout_ControlChangeCropBorder(vout, left, top, right, bottom);
+        vout_ChangeCropBorder(vout, left, top, right, bottom);
     } else if (*newval.psz_string == '\0') {
-        vout_ControlChangeCropRatio(vout, 0, 0);
+        vout_ChangeCropRatio(vout, 0, 0);
     } else {
         msg_Err(object, "Unknown crop format (%s)", newval.psz_string);
     }
@@ -496,9 +496,9 @@ static int AspectCallback( vlc_object_t *object, char const *cmd,
 
     if (sscanf(newval.psz_string, "%u:%u", &num, &den) == 2 &&
         (num != 0) == (den != 0))
-        vout_ControlChangeSampleAspectRatio(vout, num, den);
+        vout_ChangeSampleAspectRatio(vout, num, den);
     else if (*newval.psz_string == '\0')
-        vout_ControlChangeSampleAspectRatio(vout, 0, 0);
+        vout_ChangeSampleAspectRatio(vout, 0, 0);
     return VLC_SUCCESS;
 }
 
@@ -508,7 +508,7 @@ static int AutoScaleCallback( vlc_object_t *obj, char const *name,
     vout_thread_t *p_vout = (vout_thread_t *)obj;
 
     (void) name; (void) prev; (void) data;
-    vout_ControlChangeDisplayFilled( p_vout, cur.b_bool );
+    vout_ChangeDisplayFilled(p_vout, cur.b_bool);
     return VLC_SUCCESS;
 }
 
@@ -518,15 +518,15 @@ static int ZoomCallback( vlc_object_t *obj, char const *name,
     vout_thread_t *p_vout = (vout_thread_t *)obj;
 
     (void) name; (void) prev; (void) data;
-    vout_ControlChangeZoom( p_vout, 1000 * cur.f_float, 1000 );
+    vout_ChangeZoom(p_vout, 1000 * cur.f_float, 1000);
     return VLC_SUCCESS;
 }
 
 static int AboveCallback( vlc_object_t *obj, char const *name,
                           vlc_value_t prev, vlc_value_t cur, void *data )
 {
-    vout_ControlChangeWindowState( (vout_thread_t *)obj,
-        cur.b_bool ? VOUT_WINDOW_STATE_ABOVE : VOUT_WINDOW_STATE_NORMAL );
+    vout_ChangeWindowState((vout_thread_t *)obj,
+        cur.b_bool ? VOUT_WINDOW_STATE_ABOVE : VOUT_WINDOW_STATE_NORMAL);
     (void) name; (void) prev; (void) data;
     return VLC_SUCCESS;
 }
@@ -538,8 +538,8 @@ static int WallPaperCallback( vlc_object_t *obj, char const *name,
 
     if( cur.b_bool )
     {
-        vout_ControlChangeWindowState( vout, VOUT_WINDOW_STATE_BELOW );
-        vout_ControlChangeFullscreen( vout, NULL );
+        vout_ChangeWindowState(vout, VOUT_WINDOW_STATE_BELOW);
+        vout_ChangeFullscreen(vout, NULL);
     }
     else
     {
@@ -557,9 +557,9 @@ static int FullscreenCallback( vlc_object_t *p_this, char const *psz_cmd,
     (void)psz_cmd; (void) oldval; (void)p_data;
 
     if( newval.b_bool )
-        vout_ControlChangeFullscreen( p_vout, NULL );
+        vout_ChangeFullscreen(p_vout, NULL);
     else
-        vout_ControlChangeWindowed( p_vout );
+        vout_ChangeWindowed(p_vout);
     return VLC_SUCCESS;
 }
 
@@ -610,7 +610,7 @@ static int SubMarginCallback( vlc_object_t *p_this, char const *psz_cmd,
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
 
-    vout_ControlChangeSubMargin( p_vout, newval.i_int );
+    vout_ChangeSubMargin(p_vout, newval.i_int);
     return VLC_SUCCESS;
 }
 
@@ -621,6 +621,6 @@ static int ViewpointCallback( vlc_object_t *p_this, char const *psz_cmd,
     VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
 
     if( newval.p_address != NULL )
-        vout_ControlChangeViewpoint( p_vout, newval.p_address );
+        vout_ChangeViewpoint(p_vout, newval.p_address);
     return VLC_SUCCESS;
 }
diff --git a/src/video_output/window.c b/src/video_output/window.c
index b14405631f..a09aea5f14 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -152,7 +152,7 @@ static void vout_display_window_ResizeNotify(vout_window_t *window,
     vout_thread_t *vout = (vout_thread_t *)window->obj.parent;
 
     msg_Dbg(window, "resized to %ux%u", width, height);
-    vout_ControlChangeDisplaySize(vout, width, height);
+    vout_ChangeDisplaySize(vout, width, height);
 }
 
 static void vout_display_window_CloseNotify(vout_window_t *window)



More information about the vlc-commits mailing list