vtdec: Fix PAUSED->READY deadlock when output loop is running

Makes sure the GST_PAD_STREAM_LOCK is not taken when pad is being deactivated.
The lack of this was causing deadlocks when stopping the pipeline right after producing first buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6783>
This commit is contained in:
Piotr Brzeziński 2024-04-30 18:15:56 +02:00 committed by GStreamer Marge Bot
parent 10ce5a6857
commit bfb7cf7d0b

View file

@ -88,6 +88,8 @@ static gboolean gst_vtdec_flush (GstVideoDecoder * decoder);
static GstFlowReturn gst_vtdec_finish (GstVideoDecoder * decoder);
static gboolean gst_vtdec_sink_event (GstVideoDecoder * decoder,
GstEvent * event);
static GstStateChangeReturn gst_vtdec_change_state (GstElement * element,
GstStateChange transition);
static GstFlowReturn gst_vtdec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame);
@ -188,6 +190,7 @@ gst_vtdec_class_init (GstVtdecClass * klass)
gobject_class->finalize = gst_vtdec_finalize;
element_class->set_context = gst_vtdec_set_context;
element_class->change_state = gst_vtdec_change_state;
video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_vtdec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_vtdec_stop);
video_decoder_class->negotiate = GST_DEBUG_FUNCPTR (gst_vtdec_negotiate);
@ -254,6 +257,8 @@ gst_vtdec_stop (GstVideoDecoder * decoder)
GstVideoCodecFrame *frame;
GstVtdec *vtdec = GST_VTDEC (decoder);
GST_DEBUG_OBJECT (vtdec, "stop");
gst_vtdec_drain_decoder (GST_VIDEO_DECODER_CAST (vtdec), TRUE);
vtdec->downstream_ret = GST_FLOW_FLUSHING;
@ -289,8 +294,6 @@ gst_vtdec_stop (GstVideoDecoder * decoder)
gst_clear_object (&vtdec->instance);
#endif
GST_DEBUG_OBJECT (vtdec, "stop");
return TRUE;
}
@ -805,6 +808,20 @@ gst_vtdec_sink_event (GstVideoDecoder * decoder, GstEvent * event)
return ret;
}
static GstStateChangeReturn
gst_vtdec_change_state (GstElement * element, GstStateChange transition)
{
GstVtdec *self = GST_VTDEC (element);
if (transition == GST_STATE_CHANGE_PAUSED_TO_READY) {
GST_DEBUG_OBJECT (self, "pausing output loop on PAUSED->READY");
gst_vtdec_pause_output_loop (self);
}
return GST_ELEMENT_CLASS (gst_vtdec_parent_class)->change_state (element,
transition);
}
static GstFlowReturn
gst_vtdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
{