[vlc-devel] [PATCH 09/13] player: change vout events
Thomas Guillem
thomas at gllm.fr
Mon Apr 15 15:50:54 CEST 2019
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.
---
include/vlc_player.h | 30 +++++++++++++------
modules/control/gestures.c | 20 ++++++-------
modules/control/hotkeys.c | 22 +++++++-------
.../gui/qt/components/player_controller.cpp | 4 +--
src/input/player.c | 8 ++---
test/src/input/player.c | 22 +++++++-------
6 files changed, 59 insertions(+), 47 deletions(-)
diff --git a/include/vlc_player.h b/include/vlc_player.h
index 72da5d78f0..8bea0d57ac 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
{
@@ -189,6 +188,15 @@ enum vlc_player_list_action
VLC_PLAYER_LIST_UPDATED,
};
+/**
+ * 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
*
@@ -795,15 +803,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
@@ -2588,7 +2600,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 If the player was able to load a "vout window" module, the player is
* guaranteed to always hold one valid vout (that can be in the started or
@@ -2606,7 +2618,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/qt/components/player_controller.cpp b/modules/gui/qt/components/player_controller.cpp
index 5a445d174c..6899e3bca1 100644
--- a/modules/gui/qt/components/player_controller.cpp
+++ b/modules/gui/qt/components/player_controller.cpp
@@ -683,7 +683,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");
@@ -804,7 +804,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 b13713e982..0ae82f4b8b 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -1799,8 +1799,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",
@@ -1821,8 +1821,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 669a6c5013..1a2b6dd00e 100644
--- a/test/src/input/player.c
+++ b/test/src/input/player.c
@@ -102,7 +102,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) \
@@ -428,7 +428,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)
{
@@ -438,7 +438,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
@@ -565,7 +565,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);
}
@@ -861,21 +861,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
--
2.20.1
More information about the vlc-devel
mailing list