Skip to content

qt: X11 video compositor V2

Pierre Lamot requested to merge chub/vlc:x11-mt-dev into master

this MR superseded !555 (closed), I made a separate MR as the implementation is quite different. The main point of this MR is to address @rom1v points regarding the fact that when Qt main loop is stalled this blocks the rendering of the video.

I also ditched the use of GLX/EGL for the rendering process in favor of xrender, the main reason is that the implementation is simpler this way.

The composition works as follow:

  • Both the interface and the video are rendered in an offscreen window (using X11 composite extension)

  • We register to damage event (x11 damage extension) to get notified when the content of the offscreen window change. When we receive a damage event we ask the rendering part of the composition to refresh

  • A dedicated thread is spawned to do the rendering, upon a refresh event it will take the pictures from the offscreen surface and blend them into the actual window using X11 render extension. Using a separated thread from Qt ensure that the rendering of the video will not be stalled if Qt thread is busy.

One trick is that the x11 events are received on Qt main thread, this means we can no longer get notified of damage events if Qt main loop is stuck, Fortunately Qt provides a way to peek inside its event queue from another thread. We periodically poll for damage events in this queue from the rendering thread in case Qt main loop is stuck. If an event has been both peeked then received in Qt thread, the rendering request is ignored the second time we handle the event.

fixes: #25627 (closed), #22155 (closed)

UPDATES

V1: The trick using peekEventQueue has been removed as the function is no longer threadsafe in recent version. now another X11 connection is opened with the sole purpose of registering X11 damage on the video surface and receive the associated events.

V2: port damage functionalities from XLib to XCB

V3: move most X11 call outside Qt xcb connection

V4: update dependencies for snap CI image

Edited by Pierre Lamot

Merge request reports

Loading