diff options
author | Josep Torra <n770galaxy@gmail.com> | 2013-03-09 14:14:40 +0100 |
---|---|---|
committer | Josep Torra <n770galaxy@gmail.com> | 2013-03-09 14:18:13 +0100 |
commit | 38fe043a7a8f3d4a8fdccd981a3783f6fb447139 (patch) | |
tree | 0fa4810f9b5db5d20b0cfda42ad330ab82efdb1e | |
parent | d739bbae1eb29b040bd6e4c8df408e472e9a1e29 (diff) | |
download | gst-omx-38fe043a7a8f3d4a8fdccd981a3783f6fb447139.tar.gz |
omx: Fix deadlock in encoders and add explainatory comments.
-rw-r--r-- | omx/gstomxaudioenc.c | 6 | ||||
-rw-r--r-- | omx/gstomxvideodec.c | 4 | ||||
-rw-r--r-- | omx/gstomxvideoenc.c | 6 |
3 files changed, 16 insertions, 0 deletions
diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index 2e87f33..7173b15 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -652,7 +652,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 5035a3e..26ea29a 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1254,6 +1254,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 df5f755..d671293 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; |