From 3532e72eb51586fd61b97faae1efc96a39c79b4d Mon Sep 17 00:00:00 2001 From: Thomas Guillem <thomas@gllm.fr> Date: Fri, 11 Dec 2015 11:59:24 +0100 Subject: [PATCH] avcodec: abort pictures when flushing This fixes a deadlock when seeking paused. It happened when avcodec needed more pictures than VLC. It was easily reproducible with h264 in a TS file. --- modules/codec/avcodec/video.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c index 202964e294c8..6310f84e17e0 100644 --- a/modules/codec/avcodec/video.c +++ b/modules/codec/avcodec/video.c @@ -507,9 +507,17 @@ static void Flush( decoder_t *p_dec ) p_sys->i_pts = VLC_TS_INVALID; /* To make sure we recover properly */ p_sys->i_late_frames = 0; + /* Abort pictures in order to unblock all avcodec workers threads waiting + * for a picture. This will avoid a deadlock between avcodec_flush_buffers + * and workers threads */ + decoder_AbortPictures( p_dec, true ); + post_mt( p_sys ); avcodec_flush_buffers( p_context ); wait_mt( p_sys ); + + /* Reset cancel state to false */ + decoder_AbortPictures( p_dec, false ); } /***************************************************************************** -- GitLab