[vlc-devel] [PATCH 2/2] xdg-shell: acknowledge size change timely (fixes #25112)

Steve Lhomme robux4 at ycbcr.xyz
Wed Feb 10 06:45:28 UTC 2021


On 2021-02-09 18:04, remi at remlab.net wrote:
> From: RĂ©mi Denis-Courmont <remi at remlab.net>
> 
> ---
>   modules/video_output/wayland/xdg-shell.c | 32 ++++++++++++++++--------
>   1 file changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/modules/video_output/wayland/xdg-shell.c b/modules/video_output/wayland/xdg-shell.c
> index 0b0eba0be0..3a91114caf 100644
> --- a/modules/video_output/wayland/xdg-shell.c
> +++ b/modules/video_output/wayland/xdg-shell.c
> @@ -157,7 +157,20 @@ static void *Thread(void *data)
>       //return NULL;
>   }
>   
> -static void ReportSize(vout_window_t *wnd)
> +static void ResizeAck(vout_window_t *wnd, void *data)
> +{
> +#ifdef XDG_SHELL
> +    vout_window_sys_t *sys = wnd->sys;
> +    uint32_t *serial = data;
> +
> +    if (serial != NULL)
> +        xdg_surface_ack_configure(sys->surface, *serial);
> +#else
> +    (void) wnd; (void) data;
> +#endif
> +}
> +
> +static void ReportSize(vout_window_t *wnd, void *data)
>   {
>       vout_window_sys_t *sys = wnd->sys;
>       /* Zero wm.width or zero wm.height means the client should choose.
> @@ -165,7 +178,7 @@ static void ReportSize(vout_window_t *wnd)
>       unsigned width = sys->wm.width ? sys->wm.width : sys->set.width;
>       unsigned height = sys->wm.height ? sys->wm.height : sys->set.height;
>   
> -    vout_window_ReportSize(wnd, width, height);
> +    wnd->owner.cbs->resized(wnd, width, height, ResizeAck, data);
>       xdg_surface_set_window_geometry(sys->surface, 0, 0, width, height);
>   }
>   
> @@ -184,7 +197,7 @@ static void Resize(vout_window_t *wnd, unsigned width, unsigned height)
>       vlc_mutex_lock(&sys->lock);
>       sys->set.width = width;
>       sys->set.height = height;
> -    ReportSize(wnd);
> +    ReportSize(wnd, NULL);
>       vlc_mutex_unlock(&sys->lock);
>       wl_display_flush(wnd->display.wl);
>   }
> @@ -330,23 +343,22 @@ static void xdg_surface_configure_cb(void *data, struct xdg_surface *surface,
>       vout_window_t *wnd = data;
>       vout_window_sys_t *sys = wnd->sys;
>   
> -    vlc_mutex_lock(&sys->lock);
> -    sys->wm.width = sys->wm.latch.width;
> -    sys->wm.height = sys->wm.latch.height;
> -    ReportSize(wnd);
> -    vlc_mutex_unlock(&sys->lock);
> -
>       if (sys->wm.latch.fullscreen)
>           vout_window_ReportFullscreen(wnd, NULL);
>       else
>           vout_window_ReportWindowed(wnd);
>   
> -    xdg_surface_ack_configure(surface, serial);
> +    vlc_mutex_lock(&sys->lock);
> +    sys->wm.width = sys->wm.latch.width;
> +    sys->wm.height = sys->wm.latch.height;
> +    ReportSize(wnd, &serial);
> +    vlc_mutex_unlock(&sys->lock);

Now there is code that is under sys->lock that will be called under 
vout::display_lock (ResizeAck). Could this lead to deadlocks, for 
instance if the order of locking is different ?

>       vlc_mutex_lock(&sys->lock);
>       sys->wm.configured = true;
>       vlc_cond_signal(&sys->cond_configured);
>       vlc_mutex_unlock(&sys->lock);
> +    (void) surface;
>   }
>   
>   static const struct xdg_surface_listener xdg_surface_cbs =
> -- 
> 2.30.0
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list