Commit 22c80ce3 authored by Felix Abecassis's avatar Felix Abecassis

vout: fix a deadlock with the picture pool lock

A deadlock could occur in an high load situation where the vout and
the decoder are taking excessive amounts of time.

The vout thread repeatedly call ThreadDisplayPicture in its main loop
until it returns an error, while keeping the picture pool locked. If
no picture was recently received, the vout will redisplay the current
picture (a "refresh") by calling ThreadDisplayRenderPicture with
is_forced=true. If this refresh is excessively long, the vout thread
will be stuck in a refresh loop. The decoder cannot make any progress
since the picture pool lock is hold and the vout won't be polling for
control commands, yielding a total deadlock of the program.

This situation can be reproduced artificially by sleeping in the
decoder and decreasing variable VOUT_REDISPLAY_DELAY.

A simple solution to this issue is to exit the ThreadDisplayPicture
loop after refreshing. Since a refresh typically occurs when no new
pictures are received from the decoder, this should not decrease
parent c35f6c1b
......@@ -1112,6 +1112,7 @@ static int ThreadDisplayPicture(vout_thread_t *vout, mtime_t *deadline)
date_refresh = vout->p-> + VOUT_REDISPLAY_DELAY - render_delay;
refresh = date_refresh <= date;
bool force_refresh = !drop_next_frame && refresh;
if (!first && !refresh && !drop_next_frame) {
if (!frame_by_frame) {
......@@ -1133,8 +1134,9 @@ static int ThreadDisplayPicture(vout_thread_t *vout, mtime_t *deadline)
/* display the picture immediately */
bool is_forced = frame_by_frame || (!drop_next_frame && refresh) || vout->p->displayed.current->b_force;
return ThreadDisplayRenderPicture(vout, is_forced);
bool is_forced = frame_by_frame || force_refresh || vout->p->displayed.current->b_force;
int ret = ThreadDisplayRenderPicture(vout, is_forced);
return force_refresh ? VLC_EGENERIC : ret;
static void ThreadDisplaySubpicture(vout_thread_t *vout,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment