[vlc-devel] [PATCH 2/2] display: use an optional callback to reset the pictures

Steve Lhomme robux4 at ycbcr.xyz
Fri Sep 11 16:04:57 CEST 2020


Only 4 modules actually use the Reset Pictures feature to create a new filter
pipeline when they can't handle the source anymore. It's still faster than
closing the module and probing for a new display module.
---
 include/vlc_vout_display.h              | 48 ++++++++++-------------
 modules/hw/mmal/vout.c                  | 23 ++++++-----
 modules/hw/vdpau/display.c              | 52 +++++++++++++------------
 modules/video_output/android/display.c  |  4 +-
 modules/video_output/caca.c             |  2 +-
 modules/video_output/caopengllayer.m    |  6 +--
 modules/video_output/decklink.cpp       |  2 +-
 modules/video_output/fb.c               |  2 +-
 modules/video_output/flaschen.c         |  2 +-
 modules/video_output/ios.m              |  4 +-
 modules/video_output/kms.c              |  2 +-
 modules/video_output/kva.c              |  6 +--
 modules/video_output/macosx.m           |  4 +-
 modules/video_output/opengl/display.c   |  6 +--
 modules/video_output/splitter.c         |  2 +-
 modules/video_output/vdummy.c           |  4 +-
 modules/video_output/vmem.c             |  2 +-
 modules/video_output/vulkan/display.c   |  5 +--
 modules/video_output/wayland/shm.c      | 48 +++++++++++------------
 modules/video_output/win32/common.c     |  3 --
 modules/video_output/win32/direct3d11.c |  2 +-
 modules/video_output/win32/direct3d9.c  |  2 +-
 modules/video_output/win32/glwin32.c    |  2 +-
 modules/video_output/win32/wingdi.c     |  2 +-
 modules/video_output/xcb/render.c       |  4 +-
 modules/video_output/xcb/x11.c          | 17 ++++----
 modules/video_output/yuv.c              |  2 +-
 src/video_output/display.c              |  4 +-
 28 files changed, 117 insertions(+), 145 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 9c03fc5e295..5cd6f86f3ab 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -146,19 +146,6 @@ typedef struct {
  * Control query for vout_display_t
  */
 enum vout_display_query {
-    /**
-     * Asks to reset the internal buffers and picture format.
-     *
-     * This occurs after a
-     * \ref VOUT_DISPLAY_CHANGE_DISPLAY_SIZE,
-     * \ref VOUT_DISPLAY_CHANGE_DISPLAY_FILLED,
-     * \ref VOUT_DISPLAY_CHANGE_ZOOM,
-     * \ref VOUT_DISPLAY_CHANGE_SOURCE_ASPECT or
-     * \ref VOUT_DISPLAY_CHANGE_SOURCE_CROP
-     * control query returns an error.
-     */
-    VOUT_DISPLAY_RESET_PICTURES, /* video_format_t * */
-
 #if defined(__OS2__)
     /* Ask the module to acknowledge/refuse the fullscreen state change after
      * being requested (externally or by VOUT_DISPLAY_EVENT_FULLSCREEN */
@@ -171,8 +158,7 @@ enum vout_display_query {
      * Notifies a change in display size.
      *
      * \retval VLC_SUCCESS if the display handled the change
-     * \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
-     *                      is necessary
+     * \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
      */
     VOUT_DISPLAY_CHANGE_DISPLAY_SIZE,
 
@@ -180,8 +166,7 @@ enum vout_display_query {
      * Notifies a change of the display fill display flag by the user.
      *
      * \retval VLC_SUCCESS if the display handled the change
-     * \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
-     *                      is necessary
+     * \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
      */
     VOUT_DISPLAY_CHANGE_DISPLAY_FILLED,
 
@@ -189,8 +174,7 @@ enum vout_display_query {
      * Notifies a change of the user zoom factor.
      *
      * \retval VLC_SUCCESS if the display handled the change
-     * \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
-     *                      is necessary
+     * \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
      */
     VOUT_DISPLAY_CHANGE_ZOOM,
 
@@ -198,8 +182,7 @@ enum vout_display_query {
      * Notifies a change of the sample aspect ratio.
      *
      * \retval VLC_SUCCESS if the display handled the change
-     * \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
-     *                      is necessary
+     * \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
      */
     VOUT_DISPLAY_CHANGE_SOURCE_ASPECT,
 
@@ -210,8 +193,7 @@ enum vout_display_query {
      * and video_format_t::i_visible_width/height
      *
      * \retval VLC_SUCCESS if the display handled the change
-     * \retval VLC_EGENERIC if a \ref VOUT_DISPLAY_RESET_PICTURES request
-     *                      is necessary
+     * \retval VLC_EGENERIC if a \ref reset_pictures request is necessary
      */
     VOUT_DISPLAY_CHANGE_SOURCE_CROP,
 };
@@ -243,9 +225,7 @@ struct vout_display_owner_t {
  *
  * @param vd vout display context
  * @param cfg Initial and current configuration.
- * @param fmtp By default, it is equal to vd->source except for the aspect
- * ratio which is undefined(0) and is ignored. It can be changed by the module
- * to request a different format.
+ * @param fmtp It can be changed by the module to request a different format.
  * @param context XXX: to be defined.
  * @return VLC_SUCCESS or a VLC error code
  */
@@ -318,6 +298,20 @@ struct vlc_display_operations
      */
     int        (*control)(vout_display_t *, int query, va_list);
 
+    /**
+     * Reset the picture format handled by the module.
+     * This occurs after a
+     * \ref VOUT_DISPLAY_CHANGE_DISPLAY_SIZE,
+     * \ref VOUT_DISPLAY_CHANGE_DISPLAY_FILLED,
+     * \ref VOUT_DISPLAY_CHANGE_ZOOM,
+     * \ref VOUT_DISPLAY_CHANGE_SOURCE_ASPECT or
+     * \ref VOUT_DISPLAY_CHANGE_SOURCE_CROP
+     * control query returns an error.
+     *
+     * \param ftmp video format that the module expects as input
+     */
+    int       (*reset_pictures)(vout_display_t *, video_format_t *fmtp);
+
     /**
      * Notifies a change of VR/360° viewpoint.
      *
@@ -357,7 +351,7 @@ struct vout_display_t {
      * or as close as possible as \ref source.
      *
      * This can only be changed from the display module activation callback,
-     * or within a VOUT_DISPLAY_RESET_PICTURES control request.
+     * or within a \ref reset_pictures request.
      *
      * By default, it is equal to ::source except for the aspect ratio
      * which is undefined(0) and is ignored.
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index 92b88def702..f65f69f53d5 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -693,6 +693,16 @@ fail:
     sys->next_phase_check = (sys->next_phase_check + 1) % PHASE_CHECK_INTERVAL;
 }
 
+static int vd_reset_pictures(vout_display_t *vd, video_format_t *fmt)
+{
+    vout_display_sys_t * const sys = vd->sys;
+    msg_Warn(vd, "Reset Pictures");
+    kill_pool(sys);
+    *fmt = *vd->source; // Take (nearly) whatever source wants to give us
+    fmt->i_chroma = req_chroma(fmt);  // Adjust chroma to something we can actually deal with
+    return VLC_SUCCESS;
+}
+
 static int vd_control(vout_display_t *vd, int query, va_list args)
 {
     vout_display_sys_t * const sys = vd->sys;
@@ -713,17 +723,6 @@ static int vd_control(vout_display_t *vd, int query, va_list args)
                 ret = VLC_SUCCESS;
             break;
 
-        case VOUT_DISPLAY_RESET_PICTURES:
-        {
-            msg_Warn(vd, "Reset Pictures");
-            kill_pool(sys);
-            video_format_t *fmt = va_arg(args, video_format_t *);
-            *fmt = *vd->source; // Take (nearly) whatever source wants to give us
-            fmt->i_chroma = req_chroma(fmt);  // Adjust chroma to something we can actually deal with
-            ret = VLC_SUCCESS;
-            break;
-        }
-
         case VOUT_DISPLAY_CHANGE_ZOOM:
             msg_Warn(vd, "Unsupported control query %d", query);
             ret = VLC_SUCCESS;
@@ -1097,7 +1096,7 @@ static int find_display_num(const char * name)
 }
 
 static const struct vlc_display_operations ops = {
-    CloseMmalVout, vd_prepare, vd_display, vd_control, NULL,
+    CloseMmalVout, vd_prepare, vd_display, vd_control, vd_reset_pictures, NULL,
 };
 
 static int OpenMmalVout(vout_display_t *vd, const vout_display_cfg_t *cfg,
diff --git a/modules/hw/vdpau/display.c b/modules/hw/vdpau/display.c
index 73a940c8aad..1f32acfccb8 100644
--- a/modules/hw/vdpau/display.c
+++ b/modules/hw/vdpau/display.c
@@ -223,36 +223,38 @@ out:
         free(ev);
 }
 
+static int ResetPictures(vout_display_t *vd, video_format_t *fmt)
+{
+    vout_display_sys_t *sys = vd->sys;
+    const video_format_t *src= vd->source;
+    vout_display_place_t place;
+
+    msg_Dbg(vd, "resetting pictures");
+    vout_display_PlacePicture(&place, src, vd->cfg);
+
+    fmt->i_width = src->i_width * place.width / src->i_visible_width;
+    fmt->i_height = src->i_height * place.height / src->i_visible_height;
+    sys->width = fmt->i_visible_width = place.width;
+    sys->height = fmt->i_visible_height = place.height;
+    fmt->i_x_offset = src->i_x_offset * place.width / src->i_visible_width;
+    fmt->i_y_offset = src->i_y_offset * place.height / src->i_visible_height;
+
+    const uint32_t values[] = { place.x, place.y,
+                                place.width, place.height, };
+    xcb_configure_window(sys->conn, sys->window,
+                            XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y|
+                            XCB_CONFIG_WINDOW_WIDTH|XCB_CONFIG_WINDOW_HEIGHT,
+                            values);
+    xcb_flush (sys->conn);
+    return VLC_SUCCESS;
+}
+
 static int Control(vout_display_t *vd, int query, va_list ap)
 {
     vout_display_sys_t *sys = vd->sys;
 
     switch (query)
     {
-    case VOUT_DISPLAY_RESET_PICTURES:
-    {
-        video_format_t *fmt = va_arg(ap, video_format_t *);
-        const video_format_t *src= vd->source;
-        vout_display_place_t place;
-
-        msg_Dbg(vd, "resetting pictures");
-        vout_display_PlacePicture(&place, src, vd->cfg);
-
-        fmt->i_width = src->i_width * place.width / src->i_visible_width;
-        fmt->i_height = src->i_height * place.height / src->i_visible_height;
-        sys->width = fmt->i_visible_width = place.width;
-        sys->height = fmt->i_visible_height = place.height;
-        fmt->i_x_offset = src->i_x_offset * place.width / src->i_visible_width;
-        fmt->i_y_offset = src->i_y_offset * place.height / src->i_visible_height;
-
-        const uint32_t values[] = { place.x, place.y,
-                                    place.width, place.height, };
-        xcb_configure_window(sys->conn, sys->window,
-                             XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y|
-                             XCB_CONFIG_WINDOW_WIDTH|XCB_CONFIG_WINDOW_HEIGHT,
-                             values);
-        break;
-    }
     case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
     {
         vout_display_place_t place;
@@ -284,7 +286,7 @@ static int Control(vout_display_t *vd, int query, va_list ap)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Queue, Wait, Control, NULL,
+    Close, Queue, Wait, Control, ResetPictures, NULL,
 };
 
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index d2c77d7ac36..5dfa6d42660 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -477,7 +477,7 @@ static void SetRGBMask(video_format_t *p_fmt)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, NULL,
+    Close, Prepare, Display, Control, NULL, NULL,
 };
 
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
@@ -924,8 +924,6 @@ static int Control(vout_display_t *vd, int query, va_list args)
         FixSubtitleFormat(sys);
         return VLC_SUCCESS;
     }
-    case VOUT_DISPLAY_RESET_PICTURES:
-        vlc_assert_unreachable();
     default:
         msg_Warn(vd, "Unknown request in android-display: %d", query);
         return VLC_EGENERIC;
diff --git a/modules/video_output/caca.c b/modules/video_output/caca.c
index 4a8e2a24da6..060ea9c5c10 100644
--- a/modules/video_output/caca.c
+++ b/modules/video_output/caca.c
@@ -373,7 +373,7 @@ static void Close(vout_display_t *vd)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, PictureDisplay, Control, NULL,
+    Close, Prepare, PictureDisplay, Control, NULL, NULL,
 };
 
 /**
diff --git a/modules/video_output/caopengllayer.m b/modules/video_output/caopengllayer.m
index 6477fe8aa1e..21b38785d61 100644
--- a/modules/video_output/caopengllayer.m
+++ b/modules/video_output/caopengllayer.m
@@ -119,7 +119,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, PictureRender, PictureDisplay, Control, SetViewpoint,
+    Close, PictureRender, PictureDisplay, Control, NULL, SetViewpoint,
 };
 
 /*****************************************************************************
@@ -342,7 +342,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
             vout_display_place_t place;
             vout_display_PlacePicture(&place, vd->source, &cfg_tmp);
             if (unlikely(OpenglLock(sys->gl)))
-                // don't return an error or we need to handle VOUT_DISPLAY_RESET_PICTURES
+                // don't return an error or we need to handle reset_pictures
                 return VLC_SUCCESS;
 
             vout_display_opengl_SetWindowAspectRatio(sys->vgl, (float)place.width / place.height);
@@ -353,8 +353,6 @@ static int Control (vout_display_t *vd, int query, va_list ap)
             return VLC_SUCCESS;
         }
 
-        case VOUT_DISPLAY_RESET_PICTURES:
-            vlc_assert_unreachable ();
         default:
             msg_Err (vd, "Unhandled request %d", query);
             return VLC_EGENERIC;
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index ef16bf5d844..6aef6044901 100644
--- a/modules/video_output/decklink.cpp
+++ b/modules/video_output/decklink.cpp
@@ -769,7 +769,7 @@ static int ControlVideo(vout_display_t *vd, int query, va_list args)
 }
 
 static const struct vlc_display_operations ops = {
-    CloseVideo, PrepareVideo, NULL, ControlVideo, NULL,
+    CloseVideo, PrepareVideo, NULL, ControlVideo, NULL, NULL,
 };
 
 static int OpenVideo(vout_display_t *vd, const vout_display_cfg_t *cfg,
diff --git a/modules/video_output/fb.c b/modules/video_output/fb.c
index 4dc94111efd..55e9523c81f 100644
--- a/modules/video_output/fb.c
+++ b/modules/video_output/fb.c
@@ -162,7 +162,7 @@ static void ClearScreen(vout_display_sys_t *sys)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, NULL, Display, Control, NULL,
+    Close, NULL, Display, Control, NULL, NULL,
 };
 
 /**
diff --git a/modules/video_output/flaschen.c b/modules/video_output/flaschen.c
index aff7865ad63..b2e38ff838b 100644
--- a/modules/video_output/flaschen.c
+++ b/modules/video_output/flaschen.c
@@ -82,7 +82,7 @@ static void            Display(vout_display_t *, picture_t *);
 static int             Control(vout_display_t *, int, va_list);
 
 static const struct vlc_display_operations ops = {
-    Close, NULL, Display, Control, NULL,
+    Close, NULL, Display, Control, NULL, NULL,
 };
 
 /*****************************************************************************
diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index d7ffa0a16c0..a7de419cc18 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -152,7 +152,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, PictureRender, PictureDisplay, Control, SetViewpoint,
+    Close, PictureRender, PictureDisplay, Control, NULL, SetViewpoint,
 };
 
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
@@ -281,8 +281,6 @@ static int Control(vout_display_t *vd, int query, va_list ap)
             return VLC_SUCCESS;
         }
 
-        case VOUT_DISPLAY_RESET_PICTURES:
-            vlc_assert_unreachable ();
         default:
             msg_Err(vd, "Unknown request %d", query);
             return VLC_EGENERIC;
diff --git a/modules/video_output/kms.c b/modules/video_output/kms.c
index eb4c2bfde8b..78b026b97c1 100644
--- a/modules/video_output/kms.c
+++ b/modules/video_output/kms.c
@@ -663,7 +663,7 @@ static void Close(vout_display_t *vd)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, NULL,
+    Close, Prepare, Display, Control, NULL, NULL,
 };
 
 /**
diff --git a/modules/video_output/kva.c b/modules/video_output/kva.c
index 479dd9b6708..db4ab669376 100644
--- a/modules/video_output/kva.c
+++ b/modules/video_output/kva.c
@@ -156,7 +156,7 @@ static void Prepare(vout_display_t *vd, picture_t *pic, subpicture_t *subpic, vl
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, NULL,
+    Close, Prepare, Display, Control, NULL, NULL,
 };
 
 static void PMThread( void *arg )
@@ -450,10 +450,6 @@ static int Control( vout_display_t *vd, int query, va_list args )
         return VLC_SUCCESS;
     }
 
-    case VOUT_DISPLAY_RESET_PICTURES:
-        vlc_assert_unreachable();
-    }
-
     msg_Err(vd, "Unsupported query(=%d) in vout display KVA", query);
     return VLC_EGENERIC;
 }
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index af3b6dd6c5d..24fb26250db 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -138,7 +138,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, PictureRender, PictureDisplay, Control, SetViewpoint,
+    Close, PictureRender, PictureDisplay, Control, NULL, SetViewpoint,
 };
 
 static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
@@ -394,8 +394,6 @@ static int Control (vout_display_t *vd, int query, va_list ap)
                 return VLC_SUCCESS;
             }
 
-            case VOUT_DISPLAY_RESET_PICTURES:
-                vlc_assert_unreachable ();
             default:
                 msg_Err (vd, "Unknown request in Mac OS X vout display");
                 return VLC_EGENERIC;
diff --git a/modules/video_output/opengl/display.c b/modules/video_output/opengl/display.c
index a55da585c69..a9891cc658b 100644
--- a/modules/video_output/opengl/display.c
+++ b/modules/video_output/opengl/display.c
@@ -94,7 +94,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, PictureRender, PictureDisplay, Control, SetViewpoint,
+    Close, PictureRender, PictureDisplay, Control, NULL, SetViewpoint,
 };
 
 /**
@@ -235,10 +235,6 @@ static int Control (vout_display_t *vd, int query, va_list ap)
 
     switch (query)
     {
-#ifndef NDEBUG
-      case VOUT_DISPLAY_RESET_PICTURES: // not needed
-        vlc_assert_unreachable();
-#endif
 
       case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
       case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
diff --git a/modules/video_output/splitter.c b/modules/video_output/splitter.c
index e5a9d225243..57f63ad7d39 100644
--- a/modules/video_output/splitter.c
+++ b/modules/video_output/splitter.c
@@ -220,7 +220,7 @@ static vout_window_t *video_splitter_CreateWindow(vlc_object_t *obj,
 }
 
 static const struct vlc_display_operations ops = {
-    vlc_vidsplit_Close, vlc_vidsplit_Prepare, vlc_vidsplit_Display, vlc_vidsplit_Control, NULL,
+    vlc_vidsplit_Close, vlc_vidsplit_Prepare, vlc_vidsplit_Display, vlc_vidsplit_Control, NULL, NULL,
 };
 
 static int vlc_vidsplit_Open(vout_display_t *vd,
diff --git a/modules/video_output/vdummy.c b/modules/video_output/vdummy.c
index a2d83aae395..182636dfdbd 100644
--- a/modules/video_output/vdummy.c
+++ b/modules/video_output/vdummy.c
@@ -85,7 +85,7 @@ static void Open(vout_display_t *vd, video_format_t *fmt)
 }
 
 static const struct vlc_display_operations ops_dummy = {
-    NULL, NULL, NULL, Control, NULL,
+    NULL, NULL, NULL, Control, NULL, NULL,
 };
 
 static int OpenDummy(vout_display_t *vd, const vout_display_cfg_t *cfg,
@@ -98,7 +98,7 @@ static int OpenDummy(vout_display_t *vd, const vout_display_cfg_t *cfg,
 }
 
 static const struct vlc_display_operations ops_stats = {
-    NULL, NULL, DisplayStat, Control, NULL,
+    NULL, NULL, DisplayStat, Control, NULL, NULL,
 };
 
 static int OpenStats(vout_display_t *vd, const vout_display_cfg_t *cfg,
diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
index c73438eef59..125ba802378 100644
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -106,7 +106,7 @@ static void           Display(vout_display_t *, picture_t *);
 static int            Control(vout_display_t *, int, va_list);
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, NULL,
+    Close, Prepare, Display, Control, NULL, NULL,
 };
 
 /*****************************************************************************
diff --git a/modules/video_output/vulkan/display.c b/modules/video_output/vulkan/display.c
index 8167f6b1cfe..de9155c2833 100644
--- a/modules/video_output/vulkan/display.c
+++ b/modules/video_output/vulkan/display.c
@@ -78,7 +78,7 @@ static void Close(vout_display_t *);
 static void UpdateParams(vout_display_t *);
 
 static const struct vlc_display_operations ops = {
-    Close, PictureRender, PictureDisplay, Control, NULL,
+    Close, PictureRender, PictureDisplay, Control, NULL, NULL,
 };
 
 // Allocates a Vulkan surface and instance for video output.
@@ -340,9 +340,6 @@ static int Control(vout_display_t *vd, int query, va_list ap)
 
     switch (query)
     {
-    case VOUT_DISPLAY_RESET_PICTURES:
-        assert(!"VOUT_DISPLAY_RESET_PICTURES");
-
     case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
     case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
     case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
diff --git a/modules/video_output/wayland/shm.c b/modules/video_output/wayland/shm.c
index cb3532ec14c..75bd2cf9c83 100644
--- a/modules/video_output/wayland/shm.c
+++ b/modules/video_output/wayland/shm.c
@@ -152,35 +152,35 @@ static void Display(vout_display_t *vd, picture_t *pic)
     (void) pic;
 }
 
+static int ResetPictures(vout_display_t *vd, video_format_t *fmt)
+{
+    vout_display_place_t place;
+    video_format_t src;
+    vout_display_sys_t *sys = vd->sys;
+    assert(sys->viewport == NULL);
+
+    vout_display_PlacePicture(&place, vd->source, vd->cfg);
+    video_format_ApplyRotation(&src, vd->source);
+
+    fmt->i_width  = src.i_width * place.width
+                                / src.i_visible_width;
+    fmt->i_height = src.i_height * place.height
+                                    / src.i_visible_height;
+    fmt->i_visible_width  = place.width;
+    fmt->i_visible_height = place.height;
+    fmt->i_x_offset = src.i_x_offset * place.width
+                                        / src.i_visible_width;
+    fmt->i_y_offset = src.i_y_offset * place.height
+                                        / src.i_visible_height;
+    return VLC_SUCCESS;
+}
+
 static int Control(vout_display_t *vd, int query, va_list ap)
 {
     vout_display_sys_t *sys = vd->sys;
 
     switch (query)
     {
-        case VOUT_DISPLAY_RESET_PICTURES:
-        {
-            video_format_t *fmt = va_arg(ap, video_format_t *);
-            vout_display_place_t place;
-            video_format_t src;
-            assert(sys->viewport == NULL);
-
-            vout_display_PlacePicture(&place, vd->source, vd->cfg);
-            video_format_ApplyRotation(&src, vd->source);
-
-            fmt->i_width  = src.i_width * place.width
-                                        / src.i_visible_width;
-            fmt->i_height = src.i_height * place.height
-                                         / src.i_visible_height;
-            fmt->i_visible_width  = place.width;
-            fmt->i_visible_height = place.height;
-            fmt->i_x_offset = src.i_x_offset * place.width
-                                             / src.i_visible_width;
-            fmt->i_y_offset = src.i_y_offset * place.height
-                                             / src.i_visible_height;
-            break;
-        }
-
         case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
         case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
         case VOUT_DISPLAY_CHANGE_ZOOM:
@@ -263,7 +263,7 @@ static void Close(vout_display_t *vd)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, NULL,
+    Close, Prepare, Display, Control, ResetPictures, NULL, NULL,
 };
 
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index e1f6c3f5026..ea2cbf9d823 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -153,9 +153,6 @@ int CommonControl(vout_display_t *vd, display_win32_area_t *area, vout_display_s
         return VLC_SUCCESS;
     }
 
-    case VOUT_DISPLAY_RESET_PICTURES:
-        vlc_assert_unreachable();
-
     default:
         return VLC_EGENERIC;
     }
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 7863564e136..d127f669e7c 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -305,7 +305,7 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *viewpoint)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, SetViewpoint,
+    Close, Prepare, Display, Control, NULL, SetViewpoint,
 };
 
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 37720f599a7..b38cf3c1053 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1762,7 +1762,7 @@ static void LocalSwapchainSwap( void *opaque )
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, NULL,
+    Close, Prepare, Display, Control, NULL, NULL,
 };
 
 /**
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index 0cf969c1add..3606023b013 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -110,7 +110,7 @@ static vout_window_t *EmbedVideoWindow_Create(vout_display_t *vd)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, SetViewpoint,
+    Close, Prepare, Display, Control, NULL, SetViewpoint,
 };
 
 /**
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index a6970f248a6..f65cdae1226 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -105,7 +105,7 @@ static int Control(vout_display_t *vd, int query, va_list args)
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, NULL,
+    Close, Prepare, Display, Control, NULL, NULL,
 };
 
 /* */
diff --git a/modules/video_output/xcb/render.c b/modules/video_output/xcb/render.c
index c7466b2af9a..efc1906ca6b 100644
--- a/modules/video_output/xcb/render.c
+++ b/modules/video_output/xcb/render.c
@@ -373,8 +373,6 @@ static int Control(vout_display_t *vd, int query, va_list ap)
             return VLC_SUCCESS;
         }
 
-        case VOUT_DISPLAY_RESET_PICTURES:
-            vlc_assert_unreachable();
         default:
             msg_Err(vd, "Unknown request in XCB RENDER display");
             return VLC_EGENERIC;
@@ -543,7 +541,7 @@ FindVisual(const xcb_setup_t *setup, const xcb_screen_t *scr,
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, NULL,
+    Close, Prepare, Display, Control, NULL, NULL,
 };
 
 /**
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index eb702fc70c3..aaa56d87686 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -127,13 +127,20 @@ static void Display (vout_display_t *vd, picture_t *pic)
    }
 
     /* FIXME might be WAY better to wait in some case (be carefull with
-     * VOUT_DISPLAY_RESET_PICTURES if done) + does not work with
+     * reset_pictures if done) + does not work with
      * vout_display wrapper. */
 
     if (sys->attached)
         xcb_shm_detach(conn, segment);
 }
 
+static int ResetPictures(vout_display_t *vd, video_format_t *fmt)
+{
+    vout_display_sys_t *sys = vd->sys;
+    *fmt = sys->fmt;
+    return VLC_SUCCESS;
+}
+
 static int Control(vout_display_t *vd, int query, va_list ap)
 {
     vout_display_sys_t *sys = vd->sys;
@@ -178,12 +185,6 @@ static int Control(vout_display_t *vd, int query, va_list ap)
         return ret;
     }
 
-    case VOUT_DISPLAY_RESET_PICTURES:
-    {
-        *va_arg(ap, video_format_t *) = sys->fmt;
-        return VLC_SUCCESS;
-    }
-
     default:
         msg_Err (vd, "Unknown request in XCB vout display");
         return VLC_EGENERIC;
@@ -250,7 +251,7 @@ static xcb_visualid_t ScreenToFormat(const xcb_setup_t *setup,
 }
 
 static const struct vlc_display_operations ops = {
-    Close, Prepare, Display, Control, NULL,
+    Close, Prepare, Display, Control, ResetPictures, NULL,
 };
 
 /**
diff --git a/modules/video_output/yuv.c b/modules/video_output/yuv.c
index 6664a7f59a8..1f7036f3c33 100644
--- a/modules/video_output/yuv.c
+++ b/modules/video_output/yuv.c
@@ -87,7 +87,7 @@ struct vout_display_sys_t {
 };
 
 static const struct vlc_display_operations ops = {
-    Close, NULL, Display, Control, NULL,
+    Close, NULL, Display, Control, NULL, NULL,
 };
 
 /* */
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 2640ac8bde5..59814163a88 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -466,8 +466,8 @@ static void vout_display_Reset(vout_display_t *vd)
         osys->pool = NULL;
     }
 
-    if (vout_display_Control(vd, VOUT_DISPLAY_RESET_PICTURES,
-                             &osys->display_fmt)
+    assert(vd->ops->reset_pictures);
+    if (vd->ops->reset_pictures(vd, &osys->display_fmt) != VLC_SUCCESS
      || VoutDisplayCreateRender(vd))
         msg_Err(vd, "Failed to adjust render format");
 }
-- 
2.26.2



More information about the vlc-devel mailing list