[vlc-devel] [PATCH 2/2] vout: simplify the viewpoint moved handling

Steve Lhomme robux4 at ycbcr.xyz
Wed Jul 17 10:57:10 CEST 2019


We don't need a generic event callback anymore since we only handle one type of
event.

Setting a vout_display_owner_t is now optional.
---
 include/vlc_vout_display.h      | 13 +++----------
 modules/video_output/splitter.c |  5 +----
 src/video_output/display.c      |  3 ++-
 src/video_output/vout_wrapper.c | 18 ++++--------------
 4 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 6d5103cb51..77f401726d 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -189,7 +189,7 @@ struct vout_display_owner_t {
      * Be careful, it does not ensure correct serialization if it is used
      * from multiple threads.
      */
-    void            (*event)(vout_display_t *, int, va_list);
+    void (*viewpoint_moved)(void *sys, const vlc_viewpoint_t *vp);
 };
 
 /**
@@ -385,14 +385,6 @@ static inline int vout_display_Control(vout_display_t *vd, int query, ...)
     return ret;
 }
 
-static inline void vout_display_SendEvent(vout_display_t *vd, int query, ...)
-{
-    va_list args;
-    va_start(args, query);
-    vd->owner.event(vd, query, args);
-    va_end(args);
-}
-
 VLC_API void vout_display_SendEventPicturesInvalid(vout_display_t *vd);
 
 static inline void vout_display_SendEventMousePressed(vout_display_t *vd, int button)
@@ -410,7 +402,8 @@ static inline void vout_display_SendEventMouseDoubleClick(vout_display_t *vd)
 static inline void vout_display_SendEventViewpointMoved(vout_display_t *vd,
                                                         const vlc_viewpoint_t *vp)
 {
-    vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_VIEWPOINT_MOVED, vp);
+    if (vd->owner.viewpoint_moved)
+        vd->owner.viewpoint_moved(vd->owner.sys, vp);
 }
 
 /**
diff --git a/modules/video_output/splitter.c b/modules/video_output/splitter.c
index 5a30407395..8a39ccb961 100644
--- a/modules/video_output/splitter.c
+++ b/modules/video_output/splitter.c
@@ -232,10 +232,7 @@ static vout_display_t *vlc_vidsplit_CreateDisplay(vlc_object_t *obj,
     vlc_decoder_device *dec_device,
     const char *name)
 {
-    vout_display_owner_t owner = {
-        .event = vlc_vidsplit_display_Event,
-    };
-    return vout_display_New(obj, source, cfg, vctx, dec_device, name, &owner);
+    return vout_display_New(obj, source, cfg, vctx, dec_device, name, NULL);
 }
 
 static int vlc_vidsplit_Open(vout_display_t *vd,
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 90af4a071f..5537b19996 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -779,7 +779,8 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
     vd->display = NULL;
     vd->control = NULL;
     vd->sys = NULL;
-    vd->owner = *owner;
+    if (owner)
+        vd->owner = *owner;
 
     vd->module = vlc_module_load(vd, "vout display", module,
                                  module && *module != '\0',
diff --git a/src/video_output/vout_wrapper.c b/src/video_output/vout_wrapper.c
index 0870cabafa..22c0a22f50 100644
--- a/src/video_output/vout_wrapper.c
+++ b/src/video_output/vout_wrapper.c
@@ -42,20 +42,10 @@ static int  Forward(vlc_object_t *, char const *,
                     vlc_value_t, vlc_value_t, void *);
 #endif
 
-static void VoutDisplayEvent(vout_display_t *vd, int event, va_list args)
+static void VoutViewpointMoved(void *sys, const vlc_viewpoint_t *vp)
 {
-    vout_thread_t *vout = vd->owner.sys;
-
-    switch (event) {
-    case VOUT_DISPLAY_EVENT_VIEWPOINT_MOVED:
-        var_SetAddress(vout, "viewpoint-moved",
-                       (void *)va_arg(args, const vlc_viewpoint_t *));
-        break;
-    default:
-        msg_Err(vd, "VoutDisplayEvent received event %d", event);
-        /* TODO add an assert when all event are handled */
-        break;
-    }
+    vout_thread_t *vout = sys;
+    var_SetAddress(vout, "viewpoint-moved", (void*)vp);
 }
 
 /* Minimum number of display picture */
@@ -72,7 +62,7 @@ vout_display_t *vout_OpenWrapper(vout_thread_t *vout,
     vout_thread_sys_t *sys = vout->p;
     vout_display_t *vd;
     vout_display_owner_t owner = {
-        .event = VoutDisplayEvent, .sys = vout,
+        .viewpoint_moved = VoutViewpointMoved, .sys = vout,
     };
     const char *modlist;
     char *modlistbuf = NULL;
-- 
2.17.1



More information about the vlc-devel mailing list