[vlc-commits] vout: pull window lock when resizing
Rémi Denis-Courmont
git at videolan.org
Sat Jan 26 19:50:58 CET 2019
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jan 24 21:51:34 2019 +0200| [6116fd78f65a2a2d011f53da0fb0c139d561e4c8] | committer: Rémi Denis-Courmont
vout: pull window lock when resizing
We need to update the size configuration atomically w.r.t. window size
change requests. Otherwise, there is a classic ABBA race where the
configuration update and the size change are misordered.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6116fd78f65a2a2d011f53da0fb0c139d561e4c8
---
src/video_output/video_output.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 749668b19c..853232eba8 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -634,7 +634,7 @@ static void vout_ControlUpdateWindowSize(vout_thread_t *vout)
{
vout_window_t *window;
- vlc_mutex_lock(&vout->p->window_lock);
+ vlc_mutex_assert(&vout->p->window_lock);
window = vout->p->window;
if (likely(window != NULL)) {
@@ -645,7 +645,6 @@ static void vout_ControlUpdateWindowSize(vout_thread_t *vout)
msg_Dbg(vout->p->window, "requested size: %ux%u", width, height);
vout_window_SetSize(window, width, height);
}
- vlc_mutex_unlock(&vout->p->window_lock);
}
void vout_ControlChangeDisplaySize(vout_thread_t *vout,
@@ -668,6 +667,8 @@ void vout_ControlChangeDisplayFilled(vout_thread_t *vout, bool is_filled)
void vout_ControlChangeZoom(vout_thread_t *vout, unsigned num, unsigned den)
{
+ vout_thread_sys_t *sys = vout->p;
+
if (num != 0 && den != 0) {
vlc_ureduce(&num, &den, num, den, 0);
} else {
@@ -683,7 +684,10 @@ void vout_ControlChangeZoom(vout_thread_t *vout, unsigned num, unsigned den)
den = 1;
}
+ vlc_mutex_lock(&sys->window_lock);
vout_ControlUpdateWindowSize(vout);
+ vlc_mutex_unlock(&sys->window_lock);
+
vout_control_PushPair(&vout->p->control, VOUT_CONTROL_ZOOM,
num, den);
}
@@ -691,7 +695,12 @@ void vout_ControlChangeZoom(vout_thread_t *vout, unsigned num, unsigned den)
void vout_ControlChangeSampleAspectRatio(vout_thread_t *vout,
unsigned num, unsigned den)
{
+ vout_thread_sys_t *sys = vout->p;
+
+ vlc_mutex_lock(&sys->window_lock);
vout_ControlUpdateWindowSize(vout);
+ vlc_mutex_unlock(&sys->window_lock);
+
vout_control_PushPair(&vout->p->control, VOUT_CONTROL_ASPECT_RATIO,
num, den);
}
@@ -699,7 +708,12 @@ void vout_ControlChangeSampleAspectRatio(vout_thread_t *vout,
void vout_ControlChangeCropRatio(vout_thread_t *vout,
unsigned num, unsigned den)
{
+ vout_thread_sys_t *sys = vout->p;
+
+ vlc_mutex_lock(&sys->window_lock);
vout_ControlUpdateWindowSize(vout);
+ vlc_mutex_unlock(&sys->window_lock);
+
vout_control_PushPair(&vout->p->control, VOUT_CONTROL_CROP_RATIO,
num, den);
}
@@ -707,9 +721,12 @@ void vout_ControlChangeCropRatio(vout_thread_t *vout,
void vout_ControlChangeCropWindow(vout_thread_t *vout,
int x, int y, int width, int height)
{
+ vout_thread_sys_t *sys = vout->p;
vout_control_cmd_t cmd;
+ vlc_mutex_lock(&sys->window_lock);
vout_ControlUpdateWindowSize(vout);
+ vlc_mutex_unlock(&sys->window_lock);
vout_control_cmd_Init(&cmd, VOUT_CONTROL_CROP_WINDOW);
cmd.window.x = __MAX(x, 0);
@@ -722,9 +739,12 @@ void vout_ControlChangeCropWindow(vout_thread_t *vout,
void vout_ControlChangeCropBorder(vout_thread_t *vout,
int left, int top, int right, int bottom)
{
+ vout_thread_sys_t *sys = vout->p;
vout_control_cmd_t cmd;
+ vlc_mutex_lock(&sys->window_lock);
vout_ControlUpdateWindowSize(vout);
+ vlc_mutex_unlock(&sys->window_lock);
vout_control_cmd_Init(&cmd, VOUT_CONTROL_CROP_BORDER);
cmd.border.left = __MAX(left, 0);
More information about the vlc-commits
mailing list