1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 14:52:43 +00:00

vo_opengl_cb: fix a race condition

When pthread_cond_timedwait(), the condition we are checking for could
be true or false. This code assumed it was always false.

This should be an extremely obscure race condition, since it can happen
only if timeout and the condition changing sort of happen at the same
time, or the lock is held for a longer time (which it normally isn't).
But I could observe it a few times.
This commit is contained in:
wm4 2016-10-30 18:29:24 +01:00
parent b0ef3dd4fb
commit bc77565838

View File

@ -371,8 +371,10 @@ static void flip_page(struct vo *vo)
// Wait until frame was rendered
while (p->ctx->next_frame) {
if (pthread_cond_timedwait(&p->ctx->wakeup, &p->ctx->lock, &ts)) {
MP_VERBOSE(vo, "mpv_opengl_cb_draw() not being called or stuck.\n");
goto done;
if (p->ctx->next_frame) {
MP_VERBOSE(vo, "mpv_opengl_cb_draw() not being called or stuck.\n");
goto done;
}
}
}