[vlc-commits] [Git][videolan/vlc][master] 2 commits: hotkeys: factor out vout ES events
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Tue May 3 14:35:18 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
85ff09aa by Rémi Denis-Courmont at 2022-05-03T14:16:20+00:00
hotkeys: factor out vout ES events
- - - - -
dbf82a4d by Rémi Denis-Courmont at 2022-05-03T14:16:20+00:00
hotkeys: keep track of video outputs
...and properly deregister callbacks from them at exit.
Fixes #26898.
- - - - -
1 changed file:
- modules/control/hotkeys.c
Changes:
=====================================
modules/control/hotkeys.c
=====================================
@@ -43,6 +43,7 @@ struct intf_sys_t
{
vlc_playlist_t *playlist;
vlc_player_listener_id *player_listener;
+ vlc_array_t vouts;
struct
{
bool btn_pressed;
@@ -1179,6 +1180,43 @@ ViewpointMovedCallback(vlc_object_t *obj, char const *var,
return VLC_SUCCESS;
}
+static void
+player_on_vout_started(vlc_player_t *player, vout_thread_t *vout, void *data)
+{
+ intf_thread_t *intf = data;
+ intf_sys_t *sys = intf->p_sys;
+
+ if (unlikely(vlc_array_append(&sys->vouts, vout) != 0))
+ return;
+
+ var_AddCallback(vout, "mouse-button-down", MouseButtonCallback, intf);
+ var_AddCallback(vout, "mouse-moved", MouseMovedCallback, sys);
+
+ if (var_GetBool(vout, "viewpoint-changeable"))
+ var_AddCallback(vout, "viewpoint-moved",
+ ViewpointMovedCallback, player);
+}
+
+static void
+player_on_vout_stopped(vlc_player_t *player, vout_thread_t *vout, void *data)
+{
+ intf_thread_t *intf = data;
+ intf_sys_t *sys = intf->p_sys;
+ ssize_t idx = vlc_array_index_of_item(&sys->vouts, vout);
+
+ if (unlikely(idx < 0))
+ return;
+
+ vlc_array_remove(&sys->vouts, idx);
+
+ if (var_GetBool(vout, "viewpoint-changeable"))
+ var_DelCallback(vout, "viewpoint-moved",
+ ViewpointMovedCallback, player);
+
+ var_DelCallback(vout, "mouse-moved", MouseMovedCallback, sys);
+ var_DelCallback(vout, "mouse-button-down", MouseButtonCallback, intf);
+}
+
static void
player_on_vout_changed(vlc_player_t *player,
enum vlc_player_vout_action action, vout_thread_t *vout,
@@ -1186,27 +1224,17 @@ player_on_vout_changed(vlc_player_t *player,
void *data)
{
VLC_UNUSED(order);
- intf_thread_t *intf = data;
if (vlc_es_id_GetCat(es_id) != VIDEO_ES)
return;
- bool vrnav = var_GetBool(vout, "viewpoint-changeable");
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);
+ player_on_vout_started(player, vout, data);
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);
+ player_on_vout_stopped(player, vout, data);
break;
default:
vlc_assert_unreachable();
@@ -1235,6 +1263,7 @@ Open(vlc_object_t *this)
return VLC_ENOMEM;
sys->vrnav.btn_pressed = false;
sys->playlist = vlc_intf_GetMainPlaylist(intf);
+ vlc_array_init(&sys->vouts);
sys->subsync.audio_time = sys->subsync.subtitle_time = VLC_TICK_INVALID;
sys->spu_channel_order = VLC_VOUT_ORDER_PRIMARY;
static struct vlc_player_cbs const player_cbs =
@@ -1263,7 +1292,12 @@ Close(vlc_object_t *this)
vlc_player_t *player = vlc_playlist_GetPlayer(sys->playlist);
vlc_player_Lock(player);
vlc_player_RemoveListener(player, sys->player_listener);
+
+ while (sys->vouts.i_count > 0)
+ player_on_vout_stopped(player, vlc_array_item_at_index(&sys->vouts, 0),
+ intf);
vlc_player_Unlock(player);
+
var_DelCallback(vlc_object_instance(intf), "key-action", ActionCallback, intf);
free(sys);
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9c395de77cde9b6dd54d10f526f97048ff43d0fe...dbf82a4d8c0a0c583f52292144918ee33fd239a7
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9c395de77cde9b6dd54d10f526f97048ff43d0fe...dbf82a4d8c0a0c583f52292144918ee33fd239a7
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list