From: Josep Torra Date: Sat, 9 Mar 2013 13:14:40 +0000 (+0100) Subject: omx: Fix deadlock in encoders and add explainatory comments. X-Git-Tag: 1.0.0~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd071327daab59482aac93ed526064ceb4131818;p=platform%2Fupstream%2Fgst-omx.git omx: Fix deadlock in encoders and add explainatory comments. --- diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index 280187d..e49cc0a 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -634,7 +634,13 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info) GST_DEBUG_OBJECT (self, "Need to disable and drain encoder"); gst_omx_audio_enc_drain (self); gst_omx_port_set_flushing (self->enc_out_port, 5 * GST_SECOND, TRUE); + + /* Wait until the srcpad loop is finished, + * unlock GST_AUDIO_ENCODER_STREAM_LOCK to prevent deadlocks + * caused by using this lock from inside the loop function */ + GST_AUDIO_ENCODER_STREAM_UNLOCK (self); gst_pad_stop_task (GST_AUDIO_ENCODER_SRC_PAD (encoder)); + GST_AUDIO_ENCODER_STREAM_LOCK (self); if (gst_omx_port_set_enabled (self->enc_in_port, FALSE) != OMX_ErrorNone) return FALSE; diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index d731803..b49818a 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1989,6 +1989,10 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, gst_omx_video_dec_drain (self, FALSE); gst_omx_port_set_flushing (self->dec_out_port, 5 * GST_SECOND, TRUE); + + /* Wait until the srcpad loop is finished, + * unlock GST_VIDEO_DECODER_STREAM_LOCK to prevent deadlocks + * caused by using this lock from inside the loop function */ GST_VIDEO_DECODER_STREAM_UNLOCK (self); gst_pad_stop_task (GST_VIDEO_DECODER_SRC_PAD (decoder)); GST_VIDEO_DECODER_STREAM_LOCK (self); diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index c9d32c3..0e81b3b 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -1102,7 +1102,13 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, GST_DEBUG_OBJECT (self, "Need to disable and drain encoder"); gst_omx_video_enc_drain (self, FALSE); gst_omx_port_set_flushing (self->enc_out_port, 5 * GST_SECOND, TRUE); + + /* Wait until the srcpad loop is finished, + * unlock GST_VIDEO_ENCODER_STREAM_LOCK to prevent deadlocks + * caused by using this lock from inside the loop function */ + GST_VIDEO_ENCODER_STREAM_UNLOCK (self); gst_pad_stop_task (GST_VIDEO_ENCODER_SRC_PAD (encoder)); + GST_VIDEO_ENCODER_STREAM_LOCK (self); if (gst_omx_port_set_enabled (self->enc_in_port, FALSE) != OMX_ErrorNone) return FALSE;