avviddec: Unlock stream lock while waiting for decoded frame
authorSeungha Yang <seungha@centricular.com>
Thu, 16 Nov 2023 16:01:36 +0000 (01:01 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 16 Nov 2023 20:09:53 +0000 (20:09 +0000)
FFmpeg might request buffer from other threads, it will result
in deadlock

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2558
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5683>

subprojects/gst-libav/ext/libav/gstavviddec.c

index 1c10bb2..060b2f7 100644 (file)
@@ -1779,7 +1779,11 @@ gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpegdec,
    * else we might skip a reference frame */
   gst_ffmpegviddec_do_qos (ffmpegdec, frame, &mode_switch);
 
+  /* FFmpeg might request new buffer from other threads.
+   * Release lock here */
+  GST_VIDEO_DECODER_STREAM_UNLOCK (ffmpegdec);
   res = avcodec_receive_frame (ffmpegdec->context, ffmpegdec->picture);
+  GST_VIDEO_DECODER_STREAM_LOCK (ffmpegdec);
 
   /* No frames available at this time */
   if (res == AVERROR (EAGAIN)) {