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.)
This commit is contained in:
wm4 2015-11-12 22:40:02 +01:00
parent 49a41bf4df
commit b726fefe5d
1 changed files with 5 additions and 0 deletions

View File

@ -70,6 +70,7 @@ struct mpv_opengl_cb_context {
struct vo_frame *next_frame; // next frame to draw struct vo_frame *next_frame; // next frame to draw
int64_t present_count; // incremented when next frame can be shown int64_t present_count; // incremented when next frame can be shown
int64_t expected_flip_count; // next vsync event for next_frame int64_t expected_flip_count; // next vsync event for next_frame
bool redrawing; // next_frame was a redraw request
int64_t flip_count; int64_t flip_count;
struct vo_frame *cur_frame; struct vo_frame *cur_frame;
struct mp_image_params img_params; 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); assert(!p->ctx->next_frame);
p->ctx->next_frame = vo_frame_ref(frame); p->ctx->next_frame = vo_frame_ref(frame);
p->ctx->expected_flip_count = p->ctx->flip_count + 1; p->ctx->expected_flip_count = p->ctx->flip_count + 1;
p->ctx->redrawing = frame ? frame->redraw : false;
update(p); update(p);
pthread_mutex_unlock(&p->ctx->lock); pthread_mutex_unlock(&p->ctx->lock);
} }
@ -373,6 +375,9 @@ static void flip_page(struct vo *vo)
p->ctx->present_count += 1; p->ctx->present_count += 1;
pthread_cond_signal(&p->ctx->wakeup); pthread_cond_signal(&p->ctx->wakeup);
if (p->ctx->redrawing)
goto done; // do not block for redrawing
// Wait until frame was presented // Wait until frame was presented
while (p->ctx->expected_flip_count > p->ctx->flip_count) { while (p->ctx->expected_flip_count > p->ctx->flip_count) {
// mpv_opengl_cb_report_flip() is declared as optional API. // mpv_opengl_cb_report_flip() is declared as optional API.