summaryrefslogtreecommitdiffstats
path: root/player/lua
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2021-05-27 15:22:21 -0500
committerDudemanguy <random342@airmail.cc>2021-05-28 16:11:01 +0000
commitd7f3d1fff75a07bef91eef0edb9ae7db6d590637 (patch)
treeed5a9278b7b72a4b20c036e0cf4265581e34a93f /player/lua
parent151b03987947542c01624fc1819851d0bc6c2b28 (diff)
downloadmpv-d7f3d1fff75a07bef91eef0edb9ae7db6d590637.tar.bz2
mpv-d7f3d1fff75a07bef91eef0edb9ae7db6d590637.tar.xz
wayland: refactor dispatching events
This was originally just a bugfix for a race condition, but the scope expanded a bit. Currently, the wayland code does a prepare_read -> dispatch_pending -> display_flush -> read_events -> dispatch_pending routine that's basically straight from the wayland client API documentation. This essentially just queues up all the wayland events mpv has and dispatches them to the compositor. We do this for blocking purposes on every frame we render. A very similar thing is done for wait_events from the VO. This code can pretty easily be unified and split off into a separate function, vo_wayland_dispatch_events. vo_wayland_wait_frame will call this function in a while loop (which will break either on timeout or if we receive frame callback from the compositor). wait_events needs to just check this in case we get some state change on the wakeup_pipe (i.e. waking up from the paused state). As for the actual bugfix part of this, it's a slight regression from c26d833. The toplevel config event always forced a redraw when a surface became activated again. This is for something like displaying cover art on a music file. If the window was originally out of view and then later brought back into focus, no picture would be rendered (i.e. the window is just black). That's because something like cover art is just 1 frame and the VO stops doing any other additional rendering. If you miss that 1 frame, nothing would show up ever again. The fix in this case is to always just force a redraw when the mpv window comes back into view. Well with the aforementioned commit, we stopped doing wl_display_roundtrip calls on every frame. That means we no longer do roundtrip blocking calls. We just be sure to queue up all of the events we have and then dispatch them. Because wayland is fundamentally an asynchronous protocol, there's no guarantee what order these events would be processed in. This meant that on occasion, a vo_wayland_wait_frame call (this could occur multiple times depending on the exact situation) would occur before the compositor would send back frame callback. That would result in the aforementioned bug of having just a black window. The fix, in this case, is to just do a vo_wayland_wait_frame call directly before we force the VO to do a redraw. Note that merely dispatching events isn't enough because we specifically need to wait for the compositor to give us frame callback before doing a new render. P.S. fix a typo too.
Diffstat (limited to 'player/lua')
0 files changed, 0 insertions, 0 deletions