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.
This commit is contained in:
wm4 2015-07-07 13:59:33 +02:00
parent 459124f66f
commit dc33eb56f4
1 changed files with 7 additions and 1 deletions

View File

@ -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;
}
}