[vlc-devel] [PATCH 1/2] display: use a vlc_display_operations to set the display module callbacks

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


---
 include/vlc_vout_display.h              | 103 +++++++++++++-----------
 modules/hw/mmal/vout.c                  |  10 +--
 modules/hw/vdpau/display.c              |  10 +--
 modules/video_output/android/display.c  |   9 ++-
 modules/video_output/caca.c             |   9 ++-
 modules/video_output/caopengllayer.m    |  10 +--
 modules/video_output/decklink.cpp       |   9 ++-
 modules/video_output/fb.c               |   9 ++-
 modules/video_output/flaschen.c         |   9 ++-
 modules/video_output/ios.m              |  10 +--
 modules/video_output/kms.c              |   9 ++-
 modules/video_output/kva.c              |   9 ++-
 modules/video_output/macosx.m           |  10 +--
 modules/video_output/opengl/display.c   |  10 +--
 modules/video_output/splitter.c         |   9 ++-
 modules/video_output/vdummy.c           |  24 +++---
 modules/video_output/vmem.c             |   9 ++-
 modules/video_output/vulkan/display.c   |   9 ++-
 modules/video_output/wayland/shm.c      |   9 ++-
 modules/video_output/win32/direct3d11.c |  10 +--
 modules/video_output/win32/direct3d9.c  |   9 ++-
 modules/video_output/win32/glwin32.c    |  10 +--
 modules/video_output/win32/wingdi.c     |   9 ++-
 modules/video_output/xcb/render.c       |   9 ++-
 modules/video_output/xcb/x11.c          |   9 ++-
 modules/video_output/yuv.c              |   9 ++-
 src/video_output/display.c              |  23 +++---
 src/video_output/video_output.c         |   4 +-
 28 files changed, 202 insertions(+), 176 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 6935806b978..9c03fc5e295 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -262,48 +262,12 @@ typedef int (*vout_display_open_cb)(vout_display_t *vd,
     } \
     set_capability( "vout display", priority )
 
-
-struct vout_display_t {
-    struct vlc_object_t obj;
-
-    /**
-     * User configuration.
-     *
-     * This cannot be modified directly. It reflects the current values.
-     */
-    const vout_display_cfg_t *cfg;
-
-    /**
-     * Source video format.
-     *
-     * This is the format of the video that is being displayed (after decoding
-     * and filtering). It cannot be modified.
-     *
-     * \note
-     * Cropping is not requested while in the open function.
-     */
-    const video_format_t *source;
-
+struct vlc_display_operations
+{
     /**
-     * Picture format.
-     *
-     * This is the format of the pictures that are supplied to the
-     * \ref prepare and \ref display callbacks. Ideally, it should be identical
-     * 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.
-     *
-     * By default, it is equal to ::source except for the aspect ratio
-     * which is undefined(0) and is ignored.
-     */
-    const video_format_t *fmt;
-
-    /* Information
-     *
-     * You can only set them in the open function.
+     * Destroys the display.
      */
-    vout_display_info_t info;
+    void       (*close)(vout_display_t *);
 
     /**
      * Prepares a picture and an optional subpicture for display (optional).
@@ -361,25 +325,68 @@ struct vout_display_t {
      *
      * \param vp viewpoint to use on the next render
      */
-    int (*set_viewpoint)(vout_display_t *, const vlc_viewpoint_t *vp);
+    int        (*set_viewpoint)(vout_display_t *, const vlc_viewpoint_t *vp);
+};
+
+struct vout_display_t {
+    struct vlc_object_t obj;
+
+    /**
+     * User configuration.
+     *
+     * This cannot be modified directly. It reflects the current values.
+     */
+    const vout_display_cfg_t *cfg;
 
     /**
-     * Destroys the display.
+     * Source video format.
+     *
+     * This is the format of the video that is being displayed (after decoding
+     * and filtering). It cannot be modified.
+     *
+     * \note
+     * Cropping is not requested while in the open function.
      */
-    void (*close)(vout_display_t *);
+    const video_format_t *source;
 
     /**
-     * Private data for the display module.
+     * Picture format.
      *
-     * A module is free to use it as it wishes.
+     * This is the format of the pictures that are supplied to the
+     * \ref prepare and \ref display callbacks. Ideally, it should be identical
+     * 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.
+     *
+     * By default, it is equal to ::source except for the aspect ratio
+     * which is undefined(0) and is ignored.
      */
-    vout_display_sys_t *sys;
+    const video_format_t *fmt;
+
+    /* Information
+     *
+     * You can only set them in the open function.
+     */
+    vout_display_info_t info;
 
     /* Reserved for the vout_display_t owner.
      *
      * It must not be overwritten nor used directly by a module.
      */
     vout_display_owner_t owner;
+
+    /**
+     * Private data for the display module.
+     *
+     * A module is free to use it as it wishes.
+     */
+    vout_display_sys_t *sys;
+
+    /**
+     * Callbacks the display module must set on Open.
+     */
+    const struct vlc_display_operations *ops;
 };
 
 /**
@@ -426,8 +433,8 @@ VLC_API picture_t *vout_display_Prepare(vout_display_t *vd, picture_t *picture,
  */
 static inline void vout_display_Display(vout_display_t *vd, picture_t *picture)
 {
-    if (vd->display != NULL)
-        vd->display(vd, picture);
+    if (vd->ops->display != NULL)
+        vd->ops->display(vd, picture);
     picture_Release(picture);
 }
 
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index e06a24a5da4..92b88def702 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -1096,6 +1096,10 @@ static int find_display_num(const char * name)
     return display_name_to_num[i].num;
 }
 
+static const struct vlc_display_operations ops = {
+    CloseMmalVout, vd_prepare, vd_display, vd_control, NULL,
+};
+
 static int OpenMmalVout(vout_display_t *vd, const vout_display_cfg_t *cfg,
                         video_format_t *fmtp, vlc_video_context *vctx)
 {
@@ -1280,11 +1284,7 @@ static int OpenMmalVout(vout_display_t *vd, const vout_display_cfg_t *cfg,
         .subpicture_chromas = hw_mmal_vzc_subpicture_chromas
     };
 
-    vd->prepare = vd_prepare;
-    vd->display = vd_display;
-    vd->control = vd_control;
-    vd->close = CloseMmalVout;
-
+    vd->ops = &ops;
 
     return VLC_SUCCESS;
 
diff --git a/modules/hw/vdpau/display.c b/modules/hw/vdpau/display.c
index 552411e2e68..73a940c8aad 100644
--- a/modules/hw/vdpau/display.c
+++ b/modules/hw/vdpau/display.c
@@ -283,6 +283,10 @@ static int Control(vout_display_t *vd, int query, va_list ap)
     return VLC_SUCCESS;
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Queue, Wait, Control, NULL,
+};
+
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmtp, vlc_video_context *context)
 {
@@ -488,12 +492,8 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     vd->info.subpicture_chromas = spu_chromas;
     *fmtp = fmt;
 
-    vd->prepare = Queue;
-    vd->display = Wait;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
-    (void) context;
     return VLC_SUCCESS;
 
 error:
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index 2024122c05e..d2c77d7ac36 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -476,6 +476,10 @@ static void SetRGBMask(video_format_t *p_fmt)
     }
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, Display, Control, NULL,
+};
+
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmtp, vlc_video_context *context)
 {
@@ -587,10 +591,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
         UpdateVideoSize(sys, &sys->p_window->fmt);
     }
 
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     *fmtp = fmt;
 
diff --git a/modules/video_output/caca.c b/modules/video_output/caca.c
index 079d72e65ab..4a8e2a24da6 100644
--- a/modules/video_output/caca.c
+++ b/modules/video_output/caca.c
@@ -372,6 +372,10 @@ static void Close(vout_display_t *vd)
     free(sys);
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, PictureDisplay, Control, NULL,
+};
+
 /**
  * This function initializes libcaca vout method.
  */
@@ -488,10 +492,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     }
 
     /* Setup vout_display now that everything is fine */
-    vd->prepare = Prepare;
-    vd->display = PictureDisplay;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     /* Fix initial state */
     caca_refresh_display(sys->dp);
diff --git a/modules/video_output/caopengllayer.m b/modules/video_output/caopengllayer.m
index e322941003d..6477fe8aa1e 100644
--- a/modules/video_output/caopengllayer.m
+++ b/modules/video_output/caopengllayer.m
@@ -118,6 +118,10 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
     return ret;
 }
 
+static const struct vlc_display_operations ops = {
+    Close, PictureRender, PictureDisplay, Control, SetViewpoint,
+};
+
 /*****************************************************************************
  * Open: This function allocates and initializes the OpenGL vout method.
  *****************************************************************************/
@@ -209,11 +213,7 @@ static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
         /* setup vout display */
         vd->info.subpicture_chromas = subpicture_chromas;
 
-        vd->prepare = PictureRender;
-        vd->display = PictureDisplay;
-        vd->control = Control;
-        vd->set_viewpoint = SetViewpoint;
-        vd->close   = Close;
+        vd->ops = &ops;
 
         if (OSX_SIERRA_AND_HIGHER) {
             /* request our screen's HDR mode (introduced in OS X 10.11, but correctly supported in 10.12 only) */
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index 5007d5be7fe..ef16bf5d844 100644
--- a/modules/video_output/decklink.cpp
+++ b/modules/video_output/decklink.cpp
@@ -768,6 +768,10 @@ static int ControlVideo(vout_display_t *vd, int query, va_list args)
     return VLC_EGENERIC;
 }
 
+static const struct vlc_display_operations ops = {
+    CloseVideo, PrepareVideo, NULL, ControlVideo, NULL,
+};
+
 static int OpenVideo(vout_display_t *vd, const vout_display_cfg_t *cfg,
                      video_format_t *fmtp, vlc_video_context *context)
 {
@@ -805,10 +809,7 @@ static int OpenVideo(vout_display_t *vd, const vout_display_cfg_t *cfg,
         }
     }
 
-    vd->prepare = PrepareVideo;
-    vd->display = NULL;
-    vd->control = ControlVideo;
-    vd->close = CloseVideo;
+    vd->ops = &ops;
 
     vd->sys = (vout_display_sys_t*) sys;
 
diff --git a/modules/video_output/fb.c b/modules/video_output/fb.c
index 26cbbec773c..4dc94111efd 100644
--- a/modules/video_output/fb.c
+++ b/modules/video_output/fb.c
@@ -161,6 +161,10 @@ static void ClearScreen(vout_display_sys_t *sys)
     }
 }
 
+static const struct vlc_display_operations ops = {
+    Close, NULL, Display, Control, NULL,
+};
+
 /**
  * This function allocates and initializes a FB vout method.
  */
@@ -292,10 +296,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
 
     /* */
     *fmtp = fmt;
-    vd->prepare = NULL;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     (void) context;
     return VLC_SUCCESS;
diff --git a/modules/video_output/flaschen.c b/modules/video_output/flaschen.c
index 00e1e66a349..aff7865ad63 100644
--- a/modules/video_output/flaschen.c
+++ b/modules/video_output/flaschen.c
@@ -81,6 +81,10 @@ struct vout_display_sys_t {
 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,
+};
+
 /*****************************************************************************
  * Open: activates flaschen vout display method
  *****************************************************************************/
@@ -138,10 +142,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
 
     *fmtp = fmt;
 
-    vd->prepare = NULL;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     (void) cfg; (void) context;
     return VLC_SUCCESS;
diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index caaac6a9478..d7ffa0a16c0 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -151,6 +151,10 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
     return vout_display_opengl_SetViewpoint (glsys->vgl, vp);
 }
 
+static const struct vlc_display_operations ops = {
+    Close, PictureRender, PictureDisplay, Control, SetViewpoint,
+};
+
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmt, vlc_video_context *context)
 {
@@ -216,11 +220,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
         /* Setup vout_display_t once everything is fine */
         vd->info.subpicture_chromas = subpicture_chromas;
 
-        vd->prepare = PictureRender;
-        vd->display = PictureDisplay;
-        vd->control = Control;
-        vd->set_viewpoint = SetViewpoint;
-        vd->close   = Close;
+        vd->ops = &ops;
 
         return VLC_SUCCESS;
 
diff --git a/modules/video_output/kms.c b/modules/video_output/kms.c
index afe91126be8..eb4c2bfde8b 100644
--- a/modules/video_output/kms.c
+++ b/modules/video_output/kms.c
@@ -662,6 +662,10 @@ static void Close(vout_display_t *vd)
         drmDropMaster(sys->drm_fd);
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, Display, Control, NULL,
+};
+
 /**
  * This function allocates and initializes a KMS vout method.
  */
@@ -732,10 +736,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     fmt.i_chroma = sys->vlc_fourcc;
     *fmtp = fmt;
 
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     (void) context;
     return VLC_SUCCESS;
diff --git a/modules/video_output/kva.c b/modules/video_output/kva.c
index 2e576e78874..479dd9b6708 100644
--- a/modules/video_output/kva.c
+++ b/modules/video_output/kva.c
@@ -155,6 +155,10 @@ 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,
+};
+
 static void PMThread( void *arg )
 {
     struct open_init *init = ( struct open_init * )arg;
@@ -271,10 +275,7 @@ static void PMThread( void *arg )
     /* Setup vout_display now that everything is fine */
     *fmtp       = fmt;
 
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     /* Prevent SIG_FPE */
     _control87(MCW_EM, MCW_EM);
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index c8e8c0caef0..af3b6dd6c5d 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -137,6 +137,10 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
     return vout_display_opengl_SetViewpoint (sys->vgl, vp);
 }
 
+static const struct vlc_display_operations ops = {
+    Close, PictureRender, PictureDisplay, Control, SetViewpoint,
+};
+
 static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
                  video_format_t *fmt, vlc_video_context *context)
 {
@@ -247,11 +251,7 @@ static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
         /* Setup vout_display_t once everything is fine */
         vd->info.subpicture_chromas = subpicture_chromas;
 
-        vd->prepare = PictureRender;
-        vd->display = PictureDisplay;
-        vd->control = Control;
-        vd->set_viewpoint = SetViewpoint;
-        vd->close   = Close;
+        vd->ops = &ops;
 
         /* */
         // FIXME: this call leads to a fatal mutex locking error in vout_ChangeDisplaySize()
diff --git a/modules/video_output/opengl/display.c b/modules/video_output/opengl/display.c
index cfe35db0f7e..a55da585c69 100644
--- a/modules/video_output/opengl/display.c
+++ b/modules/video_output/opengl/display.c
@@ -93,6 +93,10 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *vp)
     return vout_display_opengl_SetViewpoint (sys->vgl, vp);
 }
 
+static const struct vlc_display_operations ops = {
+    Close, PictureRender, PictureDisplay, Control, SetViewpoint,
+};
+
 /**
  * Allocates a surface and an OpenGL context for video output.
  */
@@ -155,11 +159,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
 
     vd->sys = sys;
     vd->info.subpicture_chromas = spu_chromas;
-    vd->prepare = PictureRender;
-    vd->display = PictureDisplay;
-    vd->control = Control;
-    vd->set_viewpoint = SetViewpoint;
-    vd->close = Close;
+    vd->ops = &ops;
     return VLC_SUCCESS;
 
 error:
diff --git a/modules/video_output/splitter.c b/modules/video_output/splitter.c
index cc165a03de6..e5a9d225243 100644
--- a/modules/video_output/splitter.c
+++ b/modules/video_output/splitter.c
@@ -219,6 +219,10 @@ static vout_window_t *video_splitter_CreateWindow(vlc_object_t *obj,
     return window;
 }
 
+static const struct vlc_display_operations ops = {
+    vlc_vidsplit_Close, vlc_vidsplit_Prepare, vlc_vidsplit_Display, vlc_vidsplit_Control, NULL,
+};
+
 static int vlc_vidsplit_Open(vout_display_t *vd,
                              const vout_display_cfg_t *cfg,
                              video_format_t *fmtp, vlc_video_context *ctx)
@@ -303,10 +307,7 @@ static int vlc_vidsplit_Open(vout_display_t *vd,
         vlc_sem_post(&part->lock);
     }
 
-    vd->prepare = vlc_vidsplit_Prepare;
-    vd->display = vlc_vidsplit_Display;
-    vd->control = vlc_vidsplit_Control;
-    vd->close = vlc_vidsplit_Close;
+    vd->ops = &ops;
     (void) fmtp;
     return VLC_SUCCESS;
 }
diff --git a/modules/video_output/vdummy.c b/modules/video_output/vdummy.c
index 664723740fb..a2d83aae395 100644
--- a/modules/video_output/vdummy.c
+++ b/modules/video_output/vdummy.c
@@ -69,8 +69,7 @@ static int             Control(vout_display_t *, int, va_list);
 /*****************************************************************************
  * OpenVideo: activates dummy vout display method
  *****************************************************************************/
-static int Open(vout_display_t *vd, video_format_t *fmt,
-                void (*display)(vout_display_t *, picture_t *))
+static void Open(vout_display_t *vd, video_format_t *fmt)
 {
     /* p_vd->info is not modified */
 
@@ -83,25 +82,32 @@ static int Open(vout_display_t *vd, video_format_t *fmt,
         }
         free(chroma);
     }
-    vd->prepare = NULL;
-    vd->display = display;
-    vd->control = Control;
-
-    return VLC_SUCCESS;
 }
 
+static const struct vlc_display_operations ops_dummy = {
+    NULL, NULL, NULL, Control, NULL,
+};
+
 static int OpenDummy(vout_display_t *vd, const vout_display_cfg_t *cfg,
                      video_format_t *fmtp, vlc_video_context *context)
 {
     (void) cfg; (void) context;
-    return Open(vd, fmtp, NULL);
+    Open(vd, fmtp);
+    vd->ops = &ops_dummy;
+    return VLC_SUCCESS;
 }
 
+static const struct vlc_display_operations ops_stats = {
+    NULL, NULL, DisplayStat, Control, NULL,
+};
+
 static int OpenStats(vout_display_t *vd, const vout_display_cfg_t *cfg,
                      video_format_t *fmtp, vlc_video_context *context)
 {
     (void) cfg; (void) context;
-    return Open(vd, fmtp, DisplayStat);
+    Open(vd, fmtp);
+    vd->ops = &ops_stats;
+    return VLC_SUCCESS;
 }
 
 static void DisplayStat(vout_display_t *vd, picture_t *picture)
diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
index 5f7e920f757..c73438eef59 100644
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -105,6 +105,10 @@ static void           Prepare(vout_display_t *, picture_t *, subpicture_t *, vlc
 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,
+};
+
 /*****************************************************************************
  * Open: allocates video thread
  *****************************************************************************
@@ -216,10 +220,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     *fmtp = fmt;
 
     vd->sys     = sys;
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close   = Close;
+    vd->ops     = &ops;
 
     (void) cfg; (void) context;
     return VLC_SUCCESS;
diff --git a/modules/video_output/vulkan/display.c b/modules/video_output/vulkan/display.c
index 1d58b3a4763..8167f6b1cfe 100644
--- a/modules/video_output/vulkan/display.c
+++ b/modules/video_output/vulkan/display.c
@@ -77,6 +77,10 @@ static int Control(vout_display_t *, int, va_list);
 static void Close(vout_display_t *);
 static void UpdateParams(vout_display_t *);
 
+static const struct vlc_display_operations ops = {
+    Close, PictureRender, PictureDisplay, Control, NULL,
+};
+
 // Allocates a Vulkan surface and instance for video output.
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmt, vlc_video_context *context)
@@ -139,10 +143,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
 
     vd->info.subpicture_chromas = subfmts;
 
-    vd->prepare = PictureRender;
-    vd->display = PictureDisplay;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     UpdateParams(vd);
     (void) cfg; (void) context;
diff --git a/modules/video_output/wayland/shm.c b/modules/video_output/wayland/shm.c
index 27b26955cb5..cb3532ec14c 100644
--- a/modules/video_output/wayland/shm.c
+++ b/modules/video_output/wayland/shm.c
@@ -262,6 +262,10 @@ static void Close(vout_display_t *vd)
     free(sys);
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, Display, Control, NULL,
+};
+
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmtp, vlc_video_context *context)
 {
@@ -337,10 +341,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
 
     fmtp->i_chroma = VLC_CODEC_RGB32;
 
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     vlc_wl_registry_destroy(registry);
     (void) context;
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index a9405da65e1..7863564e136 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -304,6 +304,10 @@ static int SetViewpoint(vout_display_t *vd, const vlc_viewpoint_t *viewpoint)
     return VLC_SUCCESS;
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, Display, Control, SetViewpoint,
+};
+
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmtp, vlc_video_context *context)
 {
@@ -390,11 +394,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     else
         vd->info.subpicture_chromas = NULL;
 
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->set_viewpoint = SetViewpoint;
-    vd->close = Close;
+    vd->ops = &ops;
 
     msg_Dbg(vd, "Direct3D11 Open Succeeded");
 
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 2c250789190..37720f599a7 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1761,6 +1761,10 @@ static void LocalSwapchainSwap( void *opaque )
     Swap( vd );
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, Display, Control, NULL,
+};
+
 /**
  * It creates a Direct3D vout display.
  */
@@ -1871,10 +1875,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     video_format_Clean(fmtp);
     video_format_Copy(fmtp, &fmt);
 
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     /* Change the window title bar text */
     vout_window_SetTitle(cfg->window, VOUT_TITLE " (Direct3D9 output)");
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index 9d1917dde06..0cf969c1add 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -109,6 +109,10 @@ static vout_window_t *EmbedVideoWindow_Create(vout_display_t *vd)
     return wnd;
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, Display, Control, SetViewpoint,
+};
+
 /**
  * It creates an OpenGL vout display.
  */
@@ -165,11 +169,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     /* Setup vout_display now that everything is fine */
     vd->info.subpicture_chromas = subpicture_chromas;
 
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->set_viewpoint = SetViewpoint;
-    vd->close = Close;
+    vd->ops = &ops;
 
     return VLC_SUCCESS;
 
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index 5ea9246b2a8..a6970f248a6 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -104,6 +104,10 @@ static int Control(vout_display_t *vd, int query, va_list args)
     return CommonControl(vd, &sys->area, &sys->sys, query);
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, Display, Control, NULL,
+};
+
 /* */
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmtp, vlc_video_context *context)
@@ -129,10 +133,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     vout_window_SetTitle(cfg->window, VOUT_TITLE " (WinGDI output)");
 
     /* */
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
     return VLC_SUCCESS;
 
 error:
diff --git a/modules/video_output/xcb/render.c b/modules/video_output/xcb/render.c
index 14eaa06c3dc..c7466b2af9a 100644
--- a/modules/video_output/xcb/render.c
+++ b/modules/video_output/xcb/render.c
@@ -542,6 +542,10 @@ FindVisual(const xcb_setup_t *setup, const xcb_screen_t *scr,
     return 0;
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, Display, Control, NULL,
+};
+
 /**
  * Probe the X server.
  */
@@ -684,10 +688,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     sys->spu_chromas[1] = 0;
 
     vd->info.subpicture_chromas = sys->spu_chromas;
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     (void) ctx;
     return VLC_SUCCESS;
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index 8dc37cc744d..eb702fc70c3 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -249,6 +249,10 @@ static xcb_visualid_t ScreenToFormat(const xcb_setup_t *setup,
     return visual;
 }
 
+static const struct vlc_display_operations ops = {
+    Close, Prepare, Display, Control, NULL,
+};
+
 /**
  * Probe the X server.
  */
@@ -333,10 +337,7 @@ static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
 
     sys->fmt = *fmtp;
     /* Setup vout_display_t once everything is fine */
-    vd->prepare = Prepare;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     (void) context;
     return VLC_SUCCESS;
diff --git a/modules/video_output/yuv.c b/modules/video_output/yuv.c
index 62df5406f3c..6664a7f59a8 100644
--- a/modules/video_output/yuv.c
+++ b/modules/video_output/yuv.c
@@ -86,6 +86,10 @@ struct vout_display_sys_t {
     bool  is_yuv4mpeg2;
 };
 
+static const struct vlc_display_operations ops = {
+    Close, NULL, Display, Control, NULL,
+};
+
 /* */
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmtp, vlc_video_context *context)
@@ -149,10 +153,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
 
     /* */
     *fmtp = fmt;
-    vd->prepare = NULL;
-    vd->display = Display;
-    vd->control = Control;
-    vd->close = Close;
+    vd->ops = &ops;
 
     (void) cfg; (void) context;
     return VLC_SUCCESS;
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 7b49d9ce602..2640ac8bde5 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -67,7 +67,7 @@ static int vout_display_Control(vout_display_t *vd, int query, ...)
     int ret;
 
     va_start(ap, query);
-    ret = vd->control(vd, query, ap);
+    ret = vd->ops->control(vd, query, ap);
     va_end(ap);
     return ret;
 }
@@ -439,8 +439,8 @@ picture_t *vout_display_Prepare(vout_display_t *vd, picture_t *picture,
     assert(subpic == NULL); /* TODO */
     picture = vout_ConvertForDisplay(vd, picture);
 
-    if (picture != NULL && vd->prepare != NULL)
-        vd->prepare(vd, picture, subpic, date);
+    if (picture != NULL && vd->ops->prepare != NULL)
+        vd->ops->prepare(vd, picture, subpic, date);
     return picture;
 }
 
@@ -685,9 +685,9 @@ void vout_SetDisplayViewpoint(vout_display_t *vd,
 
         osys->cfg.viewpoint = *p_viewpoint;
 
-        if (vd->set_viewpoint)
+        if (vd->ops->set_viewpoint)
         {
-            if (vd->set_viewpoint(vd, &osys->cfg.viewpoint)) {
+            if (vd->ops->set_viewpoint(vd, &osys->cfg.viewpoint)) {
                 msg_Err(vd, "Failed to change Viewpoint");
                 osys->cfg.viewpoint = old_vp;
             }
@@ -736,10 +736,7 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
     vd->fmt = &osys->display_fmt;
     vd->info = (vout_display_info_t){ };
     vd->cfg = &osys->cfg;
-    vd->prepare = NULL;
-    vd->display = NULL;
-    vd->control = NULL;
-    vd->close = NULL;
+    vd->ops = NULL;
     vd->sys = NULL;
     if (owner)
         vd->owner = *owner;
@@ -759,8 +756,8 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
 #endif
 
     if (VoutDisplayCreateRender(vd)) {
-        if (vd->close != NULL)
-            vd->close(vd);
+        if (vd->ops->close != NULL)
+            vd->ops->close(vd);
         vlc_objres_clear(VLC_OBJECT(vd));
         video_format_Clean(&osys->display_fmt);
         goto error;
@@ -788,8 +785,8 @@ void vout_display_Delete(vout_display_t *vd)
     if (osys->pool != NULL)
         picture_pool_Release(osys->pool);
 
-    if (vd->close != NULL)
-        vd->close(vd);
+    if (vd->ops->close != NULL)
+        vd->ops->close(vd);
     vlc_objres_clear(VLC_OBJECT(vd));
 
     video_format_Clean(&osys->source);
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 769fed2a442..cbc66b9dbc0 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1404,8 +1404,8 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool is_forced)
     const unsigned frame_rate = todisplay->format.i_frame_rate;
     const unsigned frame_rate_base = todisplay->format.i_frame_rate_base;
 
-    if (vd->prepare != NULL)
-        vd->prepare(vd, todisplay, do_dr_spu ? subpic : NULL, system_pts);
+    if (vd->ops->prepare != NULL)
+        vd->ops->prepare(vd, todisplay, do_dr_spu ? subpic : NULL, system_pts);
 
     vout_chrono_Stop(&sys->render);
 #if 0
-- 
2.26.2



More information about the vlc-devel mailing list