From 8209ae476fd73f1e7733de7caa105771f249d040 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 12 May 2023 09:50:04 +0300 Subject: [PATCH] avviddec: Temporarily unlock stream lock while flushing buffers This can call into the decoder again from other threads and try to take the stream lock from there, which would cause a deadlock. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2558 Part-of: --- subprojects/gst-libav/ext/libav/gstavviddec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subprojects/gst-libav/ext/libav/gstavviddec.c b/subprojects/gst-libav/ext/libav/gstavviddec.c index ff38742..1c10bb2 100644 --- a/subprojects/gst-libav/ext/libav/gstavviddec.c +++ b/subprojects/gst-libav/ext/libav/gstavviddec.c @@ -2052,7 +2052,10 @@ gst_ffmpegviddec_drain (GstVideoDecoder * decoder) do { got_frame = gst_ffmpegviddec_frame (ffmpegdec, NULL, &ret); } while (got_frame && ret == GST_FLOW_OK); + + GST_VIDEO_DECODER_STREAM_UNLOCK (ffmpegdec); avcodec_flush_buffers (ffmpegdec->context); + GST_VIDEO_DECODER_STREAM_LOCK (ffmpegdec); /* FFMpeg will return AVERROR_EOF if it's internal was fully drained * then we are translating it to GST_FLOW_EOS. However, because this behavior @@ -2265,7 +2268,9 @@ gst_ffmpegviddec_flush (GstVideoDecoder * decoder) if (ffmpegdec->opened) { GST_LOG_OBJECT (decoder, "flushing buffers"); + GST_VIDEO_DECODER_STREAM_UNLOCK (ffmpegdec); avcodec_flush_buffers (ffmpegdec->context); + GST_VIDEO_DECODER_STREAM_LOCK (ffmpegdec); } return TRUE; -- 2.7.4