diff --git a/config/rpi/gstomx.conf b/config/rpi/gstomx.conf index 8b5c7d6863..d3ea56a883 100644 --- a/config/rpi/gstomx.conf +++ b/config/rpi/gstomx.conf @@ -32,7 +32,7 @@ component-name=OMX.broadcom.video_decode rank=257 in-port-index=130 out-port-index=131 -hacks=no-component-role +hacks=no-component-role;signals-premature-eos [omxtheoradec] type-name=GstOMXTheoraDec diff --git a/omx/gstomx.c b/omx/gstomx.c index b29fb6df9d..ca1fc2d37d 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -1235,6 +1235,7 @@ gst_omx_port_acquire_buffer (GstOMXPort * port, GstOMXBuffer ** buf) GstOMXComponent *comp; OMX_ERRORTYPE err; GstOMXBuffer *_buf = NULL; + gint64 timeout = GST_CLOCK_TIME_NONE; g_return_val_if_fail (port != NULL, GST_OMX_ACQUIRE_BUFFER_ERROR); g_return_val_if_fail (!port->tunneled, GST_OMX_ACQUIRE_BUFFER_ERROR); @@ -1251,6 +1252,11 @@ gst_omx_port_acquire_buffer (GstOMXPort * port, GstOMXBuffer ** buf) retry: gst_omx_component_handle_messages (comp); + /* If we are in the case where we waited for a buffer after EOS, + * make sure we don't do that again */ + if (timeout != -1) + timeout = -2; + /* Check if the component is in an error state */ if ((err = comp->last_error) != OMX_ErrorNone) { GST_ERROR_OBJECT (comp->parent, "Component %s is in error state: %s", @@ -1322,8 +1328,15 @@ retry: goto done; } - ret = GST_OMX_ACQUIRE_BUFFER_EOS; - goto done; + if (comp->hacks & GST_OMX_HACK_SIGNALS_PREMATURE_EOS && timeout != -2) { + timeout = 33 * GST_MSECOND; + + GST_DEBUG_OBJECT (comp->parent, "%s output port %u is EOS but waiting " + "in case it spits out more buffers", comp->name, port->index); + } else { + ret = GST_OMX_ACQUIRE_BUFFER_EOS; + goto done; + } } /* @@ -1339,7 +1352,8 @@ retry: if (g_queue_is_empty (&port->pending_buffers)) { GST_DEBUG_OBJECT (comp->parent, "Queue of %s port %u is empty", comp->name, port->index); - gst_omx_component_wait_message (comp, GST_CLOCK_TIME_NONE); + gst_omx_component_wait_message (comp, + timeout == -2 ? GST_CLOCK_TIME_NONE : timeout); /* And now check everything again and maybe get a buffer */ goto retry; @@ -2465,6 +2479,8 @@ gst_omx_parse_hacks (gchar ** hacks) hacks_flags |= GST_OMX_HACK_NO_COMPONENT_ROLE; else if (g_str_equal (*hacks, "no-disable-outport")) hacks_flags |= GST_OMX_HACK_NO_DISABLE_OUTPORT; + else if (g_str_equal (*hacks, "signals-premature-eos")) + hacks_flags |= GST_OMX_HACK_SIGNALS_PREMATURE_EOS; else GST_WARNING ("Unknown hack: %s", *hacks); hacks++; diff --git a/omx/gstomx.h b/omx/gstomx.h index bc9bdd05f7..60a315bcad 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -45,6 +45,11 @@ # endif #endif +/* If the component may signal EOS before it has finished pushing + * out all of its buffers. Happens with egl_render on the rpi. + */ +#define GST_OMX_HACK_SIGNALS_PREMATURE_EOS G_GUINT64_CONSTANT (0x0000000000000400) + #include #include