mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user