From b726fefe5dce46ac0bf0b7d09155ba1a0760dca9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 12 Nov 2015 22:40:02 +0100 Subject: vo_opengl_cb: do not block on flipping when redrawing Gives slightly better behavior when used with Qt. (Which tends not to flip buffers when the window is not visible.) --- video/out/vo_opengl_cb.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'video/out/vo_opengl_cb.c') diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c index a78b6a7fb7..687b9e3528 100644 --- a/video/out/vo_opengl_cb.c +++ b/video/out/vo_opengl_cb.c @@ -70,6 +70,7 @@ struct mpv_opengl_cb_context { struct vo_frame *next_frame; // next frame to draw int64_t present_count; // incremented when next frame can be shown int64_t expected_flip_count; // next vsync event for next_frame + bool redrawing; // next_frame was a redraw request int64_t flip_count; struct vo_frame *cur_frame; struct mp_image_params img_params; @@ -350,6 +351,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) assert(!p->ctx->next_frame); p->ctx->next_frame = vo_frame_ref(frame); p->ctx->expected_flip_count = p->ctx->flip_count + 1; + p->ctx->redrawing = frame ? frame->redraw : false; update(p); pthread_mutex_unlock(&p->ctx->lock); } @@ -373,6 +375,9 @@ static void flip_page(struct vo *vo) p->ctx->present_count += 1; pthread_cond_signal(&p->ctx->wakeup); + if (p->ctx->redrawing) + goto done; // do not block for redrawing + // Wait until frame was presented while (p->ctx->expected_flip_count > p->ctx->flip_count) { // mpv_opengl_cb_report_flip() is declared as optional API. -- cgit v1.2.3