diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 09f1825244..5378f607fb 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -2555,82 +2555,67 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, return FALSE; needs_disable = FALSE; } else { +#if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_EGL) + if (self->eglimage) { + gst_omx_port_set_flushing (self->dec_in_port, 5 * GST_SECOND, TRUE); + gst_omx_port_set_flushing (self->dec_out_port, 5 * GST_SECOND, TRUE); + gst_omx_port_set_flushing (self->egl_in_port, 5 * GST_SECOND, TRUE); + gst_omx_port_set_flushing (self->egl_out_port, 5 * GST_SECOND, TRUE); + } +#endif + + 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_wait_enabled (out_port, 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_EGL) if (self->eglimage) { OMX_STATETYPE egl_state; - if (gst_omx_port_set_enabled (self->dec_in_port, - FALSE) != OMX_ErrorNone) - return FALSE; - - if (gst_omx_port_set_enabled (self->dec_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 (self->dec_out_port, - 5 * GST_SECOND) != OMX_ErrorNone) - return FALSE; - - if (gst_omx_port_deallocate_buffers (self->dec_in_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_wait_enabled (self->dec_out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; - egl_state = gst_omx_component_get_state (self->egl_render, 0); if (egl_state > OMX_StateLoaded || egl_state == OMX_StateInvalid) { + if (egl_state > OMX_StateIdle) { gst_omx_component_set_state (self->egl_render, OMX_StateIdle); - gst_omx_component_get_state (self->egl_render, 5 * GST_SECOND); + gst_omx_component_set_state (self->dec, OMX_StateIdle); + egl_state = gst_omx_component_get_state (self->egl_render, + 5 * GST_SECOND); + gst_omx_component_get_state (self->dec, 1 * GST_SECOND); } gst_omx_component_set_state (self->egl_render, OMX_StateLoaded); + gst_omx_component_set_state (self->dec, OMX_StateLoaded); - gst_omx_video_dec_deallocate_output_buffers (self); gst_omx_component_close_tunnel (self->dec, self->dec_out_port, self->egl_render, self->egl_in_port); if (egl_state > OMX_StateLoaded) { gst_omx_component_get_state (self->egl_render, 5 * GST_SECOND); } + + gst_omx_component_set_state (self->dec, OMX_StateIdle); + + gst_omx_component_set_state (self->dec, OMX_StateExecuting); + gst_omx_component_get_state (self->dec, GST_CLOCK_TIME_NONE); } self->eglimage = FALSE; - } else { -#else - { - 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_wait_enabled (out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; -#endif } +#endif } if (self->input_state) gst_video_codec_state_unref (self->input_state);