[vlc-commits] vout: simplify the viewpoint moved handling

Steve Lhomme git at videolan.org
Fri Jul 19 15:29:48 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jul 17 10:29:22 2019 +0200| [693bef28d10ed4f73b5d96361b69fb094edbcbb4] | committer: Steve Lhomme

vout: simplify the viewpoint moved handling

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.

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

 include/vlc_vout_display.h      | 13 +++----------
 modules/video_output/splitter.c | 10 +---------
 src/video_output/display.c      |  3 ++-
 src/video_output/vout_wrapper.c | 18 ++++--------------
 4 files changed, 10 insertions(+), 34 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 879488c3ac..27584f7ffe 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);
 };
 
 /**
@@ -362,14 +362,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)
@@ -387,7 +379,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 de7396788d..818841ca08 100644
--- a/modules/video_output/splitter.c
+++ b/modules/video_output/splitter.c
@@ -107,11 +107,6 @@ static int vlc_vidsplit_Control(vout_display_t *vd, int query, va_list args)
     return VLC_EGENERIC;
 }
 
-static void vlc_vidsplit_display_Event(vout_display_t *p, int id, va_list ap)
-{
-    (void) p; (void) id; (void) ap;
-}
-
 static void vlc_vidsplit_Close(vout_display_t *vd)
 {
     vout_display_sys_t *sys = vd->sys;
@@ -230,10 +225,7 @@ static vout_display_t *vlc_vidsplit_CreateDisplay(vlc_object_t *obj,
     const vout_display_cfg_t *restrict cfg,
     const char *name)
 {
-    vout_display_owner_t owner = {
-        .event = vlc_vidsplit_display_Event,
-    };
-    return vout_display_New(obj, source, cfg, name, &owner);
+    return vout_display_New(obj, source, cfg, 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 2173bb084e..1b84060d5e 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -775,7 +775,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;
 
     osys->video_context.device = vlc_decoder_device_Create(osys->cfg.window);
     vlc_video_context *video_context = osys->video_context.device ?
diff --git a/src/video_output/vout_wrapper.c b/src/video_output/vout_wrapper.c
index e74c5b795a..24ef0e0448 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 */
@@ -70,7 +60,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;



More information about the vlc-commits mailing list