From f5e828ac25e6776f52c618cfedde481814c4d947 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Wed, 14 Jun 2023 12:21:10 -0500 Subject: [PATCH] vo_dmabuf_wayland: update the image of pending buffers When using a display-* video-sync mode, it is possible for buffers with a matching id to already have an image associated with them (i.e. the compositor hasn't released it yet). Previously, it was thought that we could just unref, return null, and make a new buffer but this eventually leads to a fatal error that originates from libwayland itself which stops playback. Admittedly, the reason for the error is a bit nebulous but likely it seems to be some kind of mismatch between dmabuf params and the associated image with the buffer. However, we can simplify this process greatly. Instead when the previously mentioned edge case happens, the old image can simply be freed and we give the buffer the new image. This saves creating a new buffer and also avoids that nasty libwayland error. A nice win-win all around. Fixes #11773. --- video/out/vo_dmabuf_wayland.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index 1536d6a0c9..f57e6f27ba 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -219,14 +219,10 @@ static struct buffer *buffer_check(struct vo *vo, struct mp_image *src) struct buffer *buf; wl_list_for_each(buf, &p->buffer_list, link) { if (buf->id == id) { - if (buf->image) { + if (buf->image) mp_image_unrefp(&buf->image); - buf->image = NULL; - goto done; - } else { - buf->image = src; - return buf; - } + buf->image = src; + return buf; } }