diff --git a/omx/gstomxaudiodec.c b/omx/gstomxaudiodec.c index 8b8e121498..d48239120f 100644 --- a/omx/gstomxaudiodec.c +++ b/omx/gstomxaudiodec.c @@ -843,23 +843,34 @@ gst_omx_audio_dec_set_format (GstAudioDecoder * decoder, GstCaps * caps) return FALSE; needs_disable = FALSE; } else { + /* Disabling at the same time input port and output port is only + * required when a buffer is shared between the ports. This cannot + * be the case for a decoder because its input and output buffers + * are of different nature. So let's disable ports sequencially. + * Starting from IL 1.2.0, this point has been clarified. + * OMX_SendCommand will return an error if the IL client attempts to + * call it when there is already an on-going command being processed. + * The exception is for buffer sharing above and the event + * OMX_EventPortNeedsDisable will be sent to request disabling the + * other port at the same time. */ if (gst_omx_port_set_enabled (self->dec_in_port, FALSE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_buffers_released (self->dec_in_port, 5 * GST_SECOND) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_wait_buffers_released (out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_deallocate_buffers (self->dec_in_port) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_deallocate_buffers (self->dec_out_port) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_enabled (self->dec_in_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; + + if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_wait_buffers_released (out_port, + 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_deallocate_buffers (out_port) != OMX_ErrorNone) + return FALSE; if (gst_omx_port_wait_enabled (out_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; } diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index a03ecccc46..f9c2581942 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -694,23 +694,34 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info) /* The local port_def is now obsolete so get it again. */ gst_omx_port_get_port_definition (self->enc_in_port, &port_def); } else { + /* Disabling at the same time input port and output port is only + * required when a buffer is shared between the ports. This cannot + * be the case for a encoder because its input and output buffers + * are of different nature. So let's disable ports sequencially. + * Starting from IL 1.2.0, this point has been clarified. + * OMX_SendCommand will return an error if the IL client attempts to + * call it when there is already an on-going command being processed. + * The exception is for buffer sharing above and the event + * OMX_EventPortNeedsDisable will be sent to request disabling the + * other port at the same time. */ if (gst_omx_port_set_enabled (self->enc_in_port, FALSE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_buffers_released (self->enc_in_port, 5 * GST_SECOND) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_wait_buffers_released (self->enc_out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_deallocate_buffers (self->enc_in_port) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_deallocate_buffers (self->enc_out_port) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_enabled (self->enc_in_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; + + if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_wait_buffers_released (self->enc_out_port, + 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_deallocate_buffers (self->enc_out_port) != OMX_ErrorNone) + return FALSE; if (gst_omx_port_wait_enabled (self->enc_out_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 290e5a3832..b0178b1403 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -2053,23 +2053,34 @@ gst_omx_video_dec_disable (GstOMXVideoDec * self) } #endif + /* Disabling at the same time input port and output port is only + * required when a buffer is shared between the ports. This cannot + * be the case for a decoder because its input and output buffers + * are of different nature. So let's disable ports sequencially. + * Starting from IL 1.2.0, this point has been clarified. + * OMX_SendCommand will return an error if the IL client attempts to + * call it when there is already an on-going command being processed. + * The exception is for buffer sharing above and the event + * OMX_EventPortNeedsDisable will be sent to request disabling the + * other port at the same time. */ if (gst_omx_port_set_enabled (self->dec_in_port, FALSE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_buffers_released (self->dec_in_port, 5 * GST_SECOND) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_wait_buffers_released (out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_deallocate_buffers (self->dec_in_port) != OMX_ErrorNone) return FALSE; - if (gst_omx_video_dec_deallocate_output_buffers (self) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_enabled (self->dec_in_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; + + if (gst_omx_port_set_enabled (out_port, FALSE) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_wait_buffers_released (out_port, + 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + if (gst_omx_video_dec_deallocate_output_buffers (self) != OMX_ErrorNone) + return FALSE; if (gst_omx_port_wait_enabled (out_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 3172903da1..2fc31b8061 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -1003,23 +1003,34 @@ gst_omx_video_enc_disable (GstOMXVideoEnc * self) /* The decoder is returned to initial state */ self->disabled = FALSE; } else { + /* Disabling at the same time input port and output port is only + * required when a buffer is shared between the ports. This cannot + * be the case for a encoder because its input and output buffers + * are of different nature. So let's disable ports sequencially. + * Starting from IL 1.2.0, this point has been clarified. + * OMX_SendCommand will return an error if the IL client attempts to + * call it when there is already an on-going command being processed. + * The exception is for buffer sharing above and the event + * OMX_EventPortNeedsDisable will be sent to request disabling the + * other port at the same time. */ if (gst_omx_port_set_enabled (self->enc_in_port, FALSE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_buffers_released (self->enc_in_port, 5 * GST_SECOND) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_wait_buffers_released (self->enc_out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_deallocate_buffers (self->enc_in_port) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_deallocate_buffers (self->enc_out_port) != OMX_ErrorNone) - return FALSE; if (gst_omx_port_wait_enabled (self->enc_in_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE; + + if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_wait_buffers_released (self->enc_out_port, + 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + if (gst_omx_port_deallocate_buffers (self->enc_out_port) != OMX_ErrorNone) + return FALSE; if (gst_omx_port_wait_enabled (self->enc_out_port, 1 * GST_SECOND) != OMX_ErrorNone) return FALSE;