Commit 068be492 authored by Felix Abecassis's avatar Felix Abecassis Committed by Jean-Baptiste Kempf

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
performance.

(cherry picked from commit 22c80ce310c58f6730291b4026af9c7c8b38fb63)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 5be64170
......@@ -1123,6 +1123,7 @@ static int ThreadDisplayPicture(vout_thread_t *vout, mtime_t *deadline)
date_refresh = vout->p->displayed.date + 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) {
......@@ -1144,8 +1145,9 @@ static int ThreadDisplayPicture(vout_thread_t *vout, mtime_t *deadline)
return VLC_EGENERIC;
/* 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