[vlc-commits] player: change vout events

Thomas Guillem git at videolan.org
Fri May 10 09:51:37 CEST 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Apr 15 14:04:36 2019 +0200| [aa6d395b62e3375c676cbff31cbae8099cc1f99b] | committer: Thomas Guillem

player: change vout events

No real functional changes. Changes the callback and enum names to reflect the
real event: vout are now started and stopped. The same vout can be started and
stopped several time.

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

 include/vlc_player.h                              | 30 ++++++++++++++++-------
 modules/control/gestures.c                        | 20 +++++++--------
 modules/control/hotkeys.c                         | 22 ++++++++---------
 modules/gui/macosx/playlist/VLCPlayerController.m | 10 ++++----
 modules/gui/qt/components/player_controller.cpp   |  4 +--
 src/input/player.c                                |  8 +++---
 test/src/input/player.c                           | 22 ++++++++---------
 7 files changed, 64 insertions(+), 52 deletions(-)

diff --git a/include/vlc_player.h b/include/vlc_player.h
index 897626a383..1aa5f8e687 100644
--- a/include/vlc_player.h
+++ b/include/vlc_player.h
@@ -179,8 +179,7 @@ enum vlc_player_nav
 
 /**
  * Action of vlc_player_cbs.on_track_list_changed,
- * vlc_player_cbs.on_program_list_changed, and
- * vlc_player_cbs.on_vout_list_changed callbacks
+ * vlc_player_cbs.on_program_list_changed callbacks
  */
 enum vlc_player_list_action
 {
@@ -190,6 +189,15 @@ enum vlc_player_list_action
 };
 
 /**
+ * action of vlc_player_cbs.on_vout_changed callback
+ */
+enum vlc_player_vout_action
+{
+    VLC_PLAYER_VOUT_STARTED,
+    VLC_PLAYER_VOUT_STOPPED,
+};
+
+/**
  * State of the player
  *
  * During a normal playback (no errors), the user is expected to receive all
@@ -796,15 +804,19 @@ struct vlc_player_cbs
         input_item_t *media, input_item_node_t *new_subitems, void *data);
 
     /**
-     * Called when a new vout is added or removed
+     * Called when a vout is started or stopped
+     *
+     * @note In case, several media with only one video track are played
+     * successively, the same vout instance will be started and stopped several
+     * time.
      *
      * @param player locked player instance
-     * @param action added or removed
-     * @param vout new vout
+     * @param action started or stopped
+     * @param vout vout (can't be NULL)
      * @param data opaque pointer set by vlc_player_AddListener()
      */
-    void (*on_vout_list_changed)(vlc_player_t *player,
-        enum vlc_player_list_action action, vout_thread_t *vout, void *data);
+    void (*on_vout_changed)(vlc_player_t *player,
+        enum vlc_player_vout_action action, vout_thread_t *vout, void *data);
 
     /**
      * Called when the player is corked
@@ -2607,7 +2619,7 @@ vlc_player_aout_EnableFilter(vlc_player_t *player, const char *name, bool add);
  * Get and hold the main video output
  *
  * @warning the returned vout_thread_t * must be released with vout_Release().
- * @see vlc_players_cbs.on_vout_list_changed
+ * @see vlc_players_cbs.on_vout_changed
  *
  * @note The player is guaranteed to always hold one valid vout. Only vout
  * variables can be changed from this instance. The vout returned before
@@ -2625,7 +2637,7 @@ vlc_player_vout_Hold(vlc_player_t *player);
  * @warning All vout_thread_t * element of the array must be released with
  * vout_Release(). The returned array must be freed.
  *
- * @see vlc_players_cbs.on_vout_list_changed
+ * @see vlc_players_cbs.on_vout_changed
  *
  * @param player player instance
  * @param count valid pointer to store the array count
diff --git a/modules/control/gestures.c b/modules/control/gestures.c
index 77ee8f5b39..608747f43b 100644
--- a/modules/control/gestures.c
+++ b/modules/control/gestures.c
@@ -102,9 +102,9 @@ vlc_module_begin ()
     set_callbacks( Open, Close )
 vlc_module_end ()
 
-static void player_on_vout_list_changed(vlc_player_t *player,
-                                        enum vlc_player_list_action action,
-                                        vout_thread_t *vout, void *data);
+static void player_on_vout_changed(vlc_player_t *player,
+                                   enum vlc_player_vout_action action,
+                                   vout_thread_t *vout, void *data);
 static int MovedEvent( vlc_object_t *, char const *,
                        vlc_value_t, vlc_value_t, void * );
 static int ButtonEvent( vlc_object_t *, char const *,
@@ -129,7 +129,7 @@ static int Open ( vlc_object_t *p_this )
 
     static const struct vlc_player_cbs cbs =
     {
-        .on_vout_list_changed = player_on_vout_list_changed,
+        .on_vout_changed = player_on_vout_changed,
     };
     vlc_player_t *player = vlc_playlist_GetPlayer(p_sys->playlist);
     vlc_player_Lock(player);
@@ -387,16 +387,16 @@ static int ButtonEvent( vlc_object_t *p_this, char const *psz_var,
 }
 
 static void
-player_on_vout_list_changed(vlc_player_t *player,
-                            enum vlc_player_list_action action,
-                            vout_thread_t *vout, void *data)
+player_on_vout_changed(vlc_player_t *player,
+                       enum vlc_player_vout_action action,
+                       vout_thread_t *vout, void *data)
 {
     VLC_UNUSED(player);
     intf_thread_t *intf = data;
     intf_sys_t *sys = intf->p_sys;
     switch (action)
     {
-        case VLC_PLAYER_LIST_ADDED:
+        case VLC_PLAYER_VOUT_STARTED:
             if (vlc_vector_push(&sys->vout_vector, vout))
             {
                 vout_Hold(vout);
@@ -404,7 +404,7 @@ player_on_vout_list_changed(vlc_player_t *player,
                 var_AddCallback(vout, "mouse-button-down", ButtonEvent, intf);
             }
             break;
-        case VLC_PLAYER_LIST_REMOVED:
+        case VLC_PLAYER_VOUT_STOPPED:
             for (size_t i = 0; i < sys->vout_vector.size; ++i)
             {
                 vout_thread_t *it = sys->vout_vector.data[i];
@@ -419,6 +419,6 @@ player_on_vout_list_changed(vlc_player_t *player,
             }
             break;
         default:
-            break;
+            vlc_assert_unreachable();
     }
 }
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 774d833b87..3a68846a11 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -1014,30 +1014,30 @@ ViewpointMovedCallback(vlc_object_t *obj, char const *var,
 }
 
 static void
-player_on_vout_list_changed(vlc_player_t *player,
-                            enum vlc_player_list_action action,
-                            vout_thread_t *vout,
-                            void *data)
+player_on_vout_changed(vlc_player_t *player,
+                       enum vlc_player_vout_action action, vout_thread_t *vout,
+                       void *data)
 {
-    if (action == VLC_PLAYER_LIST_UPDATED)
-        return;
     intf_thread_t *intf = data;
     bool vrnav = var_GetBool(vout, "viewpoint-changeable");
-    if (action == VLC_PLAYER_LIST_ADDED)
+    switch (action)
     {
+    case VLC_PLAYER_VOUT_STARTED:
         var_AddCallback(vout, "mouse-button-down", MouseButtonCallback, intf);
         var_AddCallback(vout, "mouse-moved", MouseMovedCallback, intf->p_sys);
         if (vrnav)
             var_AddCallback(vout, "viewpoint-moved",
                             ViewpointMovedCallback, player);
-    }
-    else
-    {
+        break;
+    case VLC_PLAYER_VOUT_STOPPED:
         var_DelCallback(vout, "mouse-button-down", MouseButtonCallback, intf);
         var_DelCallback(vout, "mouse-moved", MouseMovedCallback, intf->p_sys);
         if (vrnav)
             var_DelCallback(vout, "viewpoint-moved",
                             ViewpointMovedCallback, player);
+        break;
+    default:
+        vlc_assert_unreachable();
     }
 }
 
@@ -1065,7 +1065,7 @@ Open(vlc_object_t *this)
     sys->playlist = vlc_intf_GetMainPlaylist(intf);
     static struct vlc_player_cbs const player_cbs =
     {
-        .on_vout_list_changed = player_on_vout_list_changed,
+        .on_vout_changed = player_on_vout_changed,
     };
     vlc_player_t *player = vlc_playlist_GetPlayer(sys->playlist);
     vlc_player_Lock(player);
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m b/modules/gui/macosx/playlist/VLCPlayerController.m
index 6646247e85..463bee5946 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -426,10 +426,10 @@ static void cb_player_item_meta_changed(vlc_player_t *p_player,
     });
 }
 
-static void cb_player_vout_list_changed(vlc_player_t *p_player,
-                                        enum vlc_player_list_action action,
-                                        vout_thread_t *p_vout,
-                                        void *p_data)
+static void cb_player_vout_changed(vlc_player_t *p_player,
+                                   enum vlc_player_vout_action action,
+                                   vout_thread_t *p_vout,
+                                   void *p_data)
 {
     VLC_UNUSED(p_player);
     VLC_UNUSED(p_vout);
@@ -471,7 +471,7 @@ static const struct vlc_player_cbs player_callbacks = {
     cb_player_item_meta_changed,
     NULL, //cb_player_item_epg_changed,
     NULL, //cb_player_subitems_changed,
-    cb_player_vout_list_changed,
+    cb_player_vout_changed,
     NULL, //on_cork_changed
 };
 
diff --git a/modules/gui/qt/components/player_controller.cpp b/modules/gui/qt/components/player_controller.cpp
index 6104063a8d..0e02189b79 100644
--- a/modules/gui/qt/components/player_controller.cpp
+++ b/modules/gui/qt/components/player_controller.cpp
@@ -706,7 +706,7 @@ static void on_player_subitems_changed(vlc_player_t *, input_item_t *, input_ite
 }
 
 
-static void on_player_vout_list_changed(vlc_player_t *player, enum vlc_player_list_action, vout_thread_t *, void *data)
+static void on_player_vout_changed(vlc_player_t *player, enum vlc_player_vout_action, vout_thread_t *, void *data)
 {
     PlayerControllerPrivate* that = static_cast<PlayerControllerPrivate*>(data);
     msg_Dbg( that->p_intf, "on_player_vout_list_changed");
@@ -827,7 +827,7 @@ static const struct vlc_player_cbs player_cbs = {
     on_player_media_meta_changed,
     on_player_media_epg_changed,
     on_player_subitems_changed,
-    on_player_vout_list_changed,
+    on_player_vout_changed,
     on_player_corks_changed
 };
 
diff --git a/src/input/player.c b/src/input/player.c
index dd17406ffe..da02375a66 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -1803,8 +1803,8 @@ vlc_player_input_HandleVoutEvent(struct vlc_player_input *input,
     switch (ev->action)
     {
         case VLC_INPUT_EVENT_VOUT_ADDED:
-            vlc_player_SendEvent(player, on_vout_list_changed,
-                                 VLC_PLAYER_LIST_ADDED, ev->vout);
+            vlc_player_SendEvent(player, on_vout_changed,
+                                 VLC_PLAYER_VOUT_STARTED, ev->vout);
 
             /* Register vout callbacks after the vout list event */
             var_AddCallback(ev->vout, "fullscreen",
@@ -1825,8 +1825,8 @@ vlc_player_input_HandleVoutEvent(struct vlc_player_input *input,
                 var_DelCallback(ev->vout, osd_vars[i],
                                 vlc_player_VoutOSDCallback, player);
 
-            vlc_player_SendEvent(player, on_vout_list_changed,
-                                 VLC_PLAYER_LIST_REMOVED, ev->vout);
+            vlc_player_SendEvent(player, on_vout_changed,
+                                 VLC_PLAYER_VOUT_STOPPED, ev->vout);
             break;
         default:
             vlc_assert_unreachable();
diff --git a/test/src/input/player.c b/test/src/input/player.c
index c30f6128dd..16264eb96e 100644
--- a/test/src/input/player.c
+++ b/test/src/input/player.c
@@ -108,7 +108,7 @@ struct report_media_subitems
     X(bool, on_recording_changed) \
     X(struct report_signal, on_signal_changed) \
     X(struct input_stats_t, on_statistics_changed) \
-    X(struct report_vout_list, on_vout_list_changed) \
+    X(struct report_vout_list, on_vout_changed) \
     X(input_item_t *, on_media_meta_changed) \
     X(input_item_t *, on_media_epg_changed) \
     X(struct report_media_subitems, on_media_subitems_changed) \
@@ -438,7 +438,7 @@ player_on_statistics_changed(vlc_player_t *player,
 }
 
 static void
-player_on_vout_list_changed(vlc_player_t *player,
+player_on_vout_changed(vlc_player_t *player,
                             enum vlc_player_list_action action,
                             vout_thread_t *vout, void *data)
 {
@@ -448,7 +448,7 @@ player_on_vout_list_changed(vlc_player_t *player,
         .vout = vout,
     };
     vout_Hold(vout);
-    VEC_PUSH(on_vout_list_changed, report);
+    VEC_PUSH(on_vout_changed, report);
 }
 
 static void
@@ -575,7 +575,7 @@ ctx_reset(struct ctx *ctx)
 
     {
         struct report_vout_list report;
-        FOREACH_VEC(report, on_vout_list_changed)
+        FOREACH_VEC(report, on_vout_changed)
             vout_Release(report.vout);
     }
 
@@ -872,21 +872,21 @@ test_end_poststop_titles(struct ctx *ctx)
 static void
 test_end_poststop_vouts(struct ctx *ctx)
 {
-    vec_on_vout_list_changed *vec = &ctx->report.on_vout_list_changed;
+    vec_on_vout_changed *vec = &ctx->report.on_vout_changed;
 
-    size_t vout_added = 0, vout_removed = 0;
+    size_t vout_started = 0, vout_stopped = 0;
 
     struct report_vout_list report;
     vlc_vector_foreach(report, vec)
     {
-        if (report.action == VLC_PLAYER_LIST_ADDED)
-            vout_added++;
-        else if (report.action == VLC_PLAYER_LIST_REMOVED)
-            vout_removed++;
+        if (report.action == VLC_PLAYER_VOUT_STARTED)
+            vout_started++;
+        else if (report.action == VLC_PLAYER_VOUT_STOPPED)
+            vout_stopped++;
         else
             vlc_assert_unreachable();
     }
-    assert(vout_added == vout_removed);
+    assert(vout_started == vout_stopped);
 }
 
 static void



More information about the vlc-commits mailing list