[vlc-commits] vout: fix race to update window size
Rémi Denis-Courmont
git at videolan.org
Fri Jun 14 05:31:28 CEST 2019
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jun 12 20:36:50 2019 +0300| [3784e7066210441174f1937151b60d3ae3bbb80a] | committer: Rémi Denis-Courmont
vout: fix race to update window size
Locking the window does not guarantee that the original format will not
change. Lock the display and check if there is a display: the original
format cannot change while a display exists.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3784e7066210441174f1937151b60d3ae3bbb80a
---
src/video_output/video_output.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 0fd6790b44..dea2d82f98 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -201,17 +201,20 @@ static void vout_SizeWindow(vout_thread_t *vout, unsigned *restrict width,
static void vout_UpdateWindowSizeLocked(vout_thread_t *vout)
{
+ vout_thread_sys_t *sys = vout->p;
unsigned width, height;
- vlc_mutex_assert(&vout->p->window_lock);
+ vlc_mutex_assert(&sys->window_lock);
-#warning Data race! /* Window lock does not protect original format */
- if (vout->p->original.i_chroma == 0)
- return;
+ vlc_mutex_lock(&sys->display_lock);
+ if (sys->display != NULL) {
+ vout_SizeWindow(vout, &width, &height);
+ vlc_mutex_unlock(&sys->display_lock);
- vout_SizeWindow(vout, &width, &height);
- msg_Dbg(vout, "requested window size: %ux%u", width, height);
- vout_window_SetSize(vout->p->display_cfg.window, width, height);
+ msg_Dbg(vout, "requested window size: %ux%u", width, height);
+ vout_window_SetSize(vout->p->display_cfg.window, width, height);
+ } else
+ vlc_mutex_unlock(&sys->display_lock);
}
/* */
More information about the vlc-commits
mailing list