vout: add a resize acknowledgement callback
commit919ba1c9d3f66bda7b737824f87651ad9014d72c
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 9 Feb 2021 16:39:56 +0000 (9 18:39 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 15 Mar 2021 17:10:18 +0000 (15 19:10 +0200)
tree89f407c4f62b4102f388c48b385f74c19b1c1faa
parent931ec8b2de2c8be30ad272157da462afbbf35634
vout: add a resize acknowledgement callback

For perfect rendering synchronisation, the change of window size must
be acknowledged after the last picture is rendered in the old size,
and before the first picture is rendered in the new size.

As of c9d6d95f291b1e2c0e4f374f87790af091282c1e, the window resize is
processed synchronously. This provides for the "after" requirement. But
it failed to address the "before" requirement: the video output thread
can end render a picture so soon after the resize so the window
callback thread has not had time to perform acknowledgement procedures.

This adds a callback to the window resize event which is called before
the display lock (or equivalent) is released. This is guaranteed to be
invoked before the video output thread has the opportunity to render
anything.

Other options were considered:

1) Invoking a callback to the window provider from the video output
   thread code code.
   -> This can delay the callback unreasonably.
   -> Taking the window lock on the video output thread is undesirable
      if at all possible.

2) Invoking a windowing system type-specific callback to the window
   provider from every display of that windowing system.
   -> Same delay and locking problems as 1.
   -> Requires patching several display plugins.

3) Exposing the display lock to the window plugin, via new callbacks.
   -> This leaks internal implementation of the core to window
      providers.
   -> This gets really confusing as some callbacks would need explicit
      locking and others not.

In comparison, this patch seems like the least of evils.

The callback is passed a parameter rather than as a property of the
window to distinguish it from the existing window callbacks which are
not reentrant.

Refs #25112.
include/vlc_vout_window.h
modules/video_output/splitter.c
src/video_output/opengl.c
src/video_output/video_output.c
src/video_output/vout_internal.h
src/video_output/window.c