From dc33eb56f4ae28b75ddc4127bd9e766606096c25 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 7 Jul 2015 13:59:33 +0200 Subject: [PATCH] vo_opengl_cb: drop frames eagerly if frames are not rendered libmpv users might stop calling the frame render callback for stupid reasons, at which point video frames would pile up. --- video/out/vo_opengl_cb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c index 7cd44c2c29..217e15d76a 100644 --- a/video/out/vo_opengl_cb.c +++ b/video/out/vo_opengl_cb.c @@ -82,6 +82,7 @@ struct mpv_opengl_cb_context { struct mp_csp_equalizer eq; int64_t recent_flip; int64_t approx_vsync; + bool frozen; // libmpv user is not redrawing frames // --- All of these can only be accessed from the thread where the host // application's OpenGL context is current - i.e. only while the @@ -309,6 +310,7 @@ int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h) struct vo *vo = ctx->active; ctx->force_update |= ctx->reconfigured; + ctx->frozen = false; if (ctx->vp_w != vp_w || ctx->vp_h != vp_h) ctx->force_update = true; @@ -432,8 +434,12 @@ static void flip_page(struct vo *vo) break; case FRAME_DROP_BLOCK: ; struct timespec ts = mp_rel_time_to_timespec(0.2); - if (pthread_cond_timedwait(&p->ctx->wakeup, &p->ctx->lock, &ts)) + if (p->ctx->frozen || + pthread_cond_timedwait(&p->ctx->wakeup, &p->ctx->lock, &ts)) + { frame_queue_drop_all(p->ctx); + p->ctx->frozen = true; + } break; } }