summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2023-05-12 09:50:04 +0300
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2023-05-13 10:20:32 +0000
commit186d8a99cc67b6da6457f2495cdbc3bc9c9f20b1 (patch)
treeffc1bfac8601625f712a33932e9f09019d4f4351
parente34397ab0985fe04e7fc50fb6d7b26e997941d26 (diff)
downloadgstreamer-186d8a99cc67b6da6457f2495cdbc3bc9c9f20b1.tar.gz
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4610>
-rw-r--r--subprojects/gst-libav/ext/libav/gstavviddec.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/subprojects/gst-libav/ext/libav/gstavviddec.c b/subprojects/gst-libav/ext/libav/gstavviddec.c
index cc7b6012bd..72985da314 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;