diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2015-08-19 22:41:26 +0300 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-08-21 00:01:01 +0200 |
commit | e05dc7bfb7c8a2d0c461cb1d60386f067bd01061 (patch) | |
tree | 6d9799398a092797a5ee43954fa68387070167c8 /video/out/vo_wayland.c | |
parent | 3245bfefc3803904f5aeade0b3e60cd504ccb16c (diff) | |
download | mpv-e05dc7bfb7c8a2d0c461cb1d60386f067bd01061.tar.bz2 mpv-e05dc7bfb7c8a2d0c461cb1d60386f067bd01061.tar.xz |
vo_wayland: Wait for frame callbacks
Privdes small api for vo_wayland where one can request frame callback
and then wait for it.
This will make vo_wayland play video smoothly.
Diffstat (limited to 'video/out/vo_wayland.c')
-rw-r--r-- | video/out/vo_wayland.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/video/out/vo_wayland.c b/video/out/vo_wayland.c index 3367e46fe6..5d3c77e2bf 100644 --- a/video/out/vo_wayland.c +++ b/video/out/vo_wayland.c @@ -389,14 +389,12 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) p->original_image = mpi; } - if (!p->wl->frame.pending) - return; + if (!vo_wayland_wait_frame(vo)) + MP_DBG(p->wl, "discarding frame callback\n"); shm_buffer_t *buf = buffer_pool_get_back(&p->video_bufpool); if (!buf) { - // TODO: use similar handling of busy buffers as the osd buffers - // if the need arises MP_VERBOSE(p->wl, "can't draw, back buffer is busy\n"); return; } @@ -504,25 +502,31 @@ static void draw_osd(struct vo *vo) osd_draw(vo->osd, p->osd, pts, 0, osd_formats, draw_osd_cb, p); } -static void flip_page(struct vo *vo) +static void redraw(void *data, uint32_t time) { - struct priv *p = vo->priv; - - if (!p->wl->frame.pending) - return; - - buffer_pool_swap(&p->video_bufpool); + struct priv *p = data; shm_buffer_t *buf = buffer_pool_get_front(&p->video_bufpool); wl_surface_attach(p->wl->window.video_surface, buf->buffer, p->x, p->y); wl_surface_damage(p->wl->window.video_surface, 0, 0, p->dst_w, p->dst_h); - wl_surface_commit(p->wl->window.video_surface); buffer_finalise_front(buf); p->x = 0; p->y = 0; p->recent_flip_time = mp_time_us(); - p->wl->frame.pending = false; +} + +static void flip_page(struct vo *vo) +{ + struct priv *p = vo->priv; + + buffer_pool_swap(&p->video_bufpool); + + if (!p->wl->frame.callback) + vo_wayland_request_frame(vo, p, redraw); + + if (!vo_wayland_wait_frame(vo)) + MP_DBG(p->wl, "discarding frame callback\n"); } static int query_format(struct vo *vo, int format) |