diff options
author | Dudemanguy <random342@airmail.cc> | 2023-10-01 01:19:40 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-10-03 23:45:20 +0000 |
commit | 7b8a30fc8132203bc93d35ac887682d2044ad5a9 (patch) | |
tree | 3ab055580db0e1eaadd9395945562a3ea6c4f424 /video/out/vo.c | |
parent | d147a06e60bfc10cb2fd7c66af7eb6871dba163e (diff) | |
download | mpv-7b8a30fc8132203bc93d35ac887682d2044ad5a9.tar.bz2 mpv-7b8a30fc8132203bc93d35ac887682d2044ad5a9.tar.xz |
vo_dmabuf_wayland: eliminate an extra frame copy
When implementing vo_dmabuf_wayland, it always did a copy of the image
from the current frame and worked with that. The reason was because
mpv's core held onto the frame and caused some timing issues and
rendering glitches depending on when it freed the image. This is pretty
easy to fix: just make vo_dmabuf_wayland manage the the frames. In vo.h,
we add a boolean that a VO can set to make them manage freeing frames
directly. After doing this, change the buffers in vo_dmabuf_wayland to
store the whole vo_frame instead of just the image. Then, just modify
some things a bit so frame is freed instead of the image. Now, we should
truly have zero-copy playback. Well as long as you don't use libass to
render anything (that's still a copy from system memory).
Diffstat (limited to 'video/out/vo.c')
-rw-r--r-- | video/out/vo.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/video/out/vo.c b/video/out/vo.c index 84a900af5b..420b5b44c9 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -1026,7 +1026,8 @@ static bool render_frame(struct vo *vo) pthread_cond_broadcast(&in->wakeup); // for vo_wait_frame() done: - talloc_free(frame); + if (!vo->driver->frame_owner) + talloc_free(frame); if (in->wakeup_on_done && !still_displaying(vo)) { in->wakeup_on_done = false; wakeup_core(vo); @@ -1064,7 +1065,7 @@ static void do_redraw(struct vo *vo) vo->driver->draw_frame(vo, frame); vo->driver->flip_page(vo); - if (frame != &dummy) + if (frame != &dummy && !vo->driver->frame_owner) talloc_free(frame); } |