[Gstreamer-openmax] [PATCH 4/5] basesink: align gst and omx states in base_sink
Felipe Contreras
felipe.contreras at gmail.com
Tue Mar 24 14:59:06 PDT 2009
Based on the tunneling patch series by Frederik Vermelen (NXP), whom
also gave feedback to this patch.
Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
---
omx/gstomx_base_sink.c | 94 +++++++++++++++++++++--------------------------
omx/gstomx_base_sink.h | 1 -
2 files changed, 42 insertions(+), 53 deletions(-)
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index 2e29312..f2b3d0a 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -78,31 +78,47 @@ change_state (GstElement *element,
gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+ switch (transition)
+ {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ g_omx_core_prepare (self->gomx);
+ break;
- GST_LOG_OBJECT (self, "end");
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ g_omx_core_start (self->gomx);
+ break;
- return ret;
-}
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ g_omx_port_finish (self->in_port);
+ break;
-static gboolean
-stop (GstBaseSink *gst_base)
-{
- GstOmxBaseSink *self;
+ default:
+ break;
+ }
- self = GST_OMX_BASE_SINK (gst_base);
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- GST_LOG_OBJECT (self, "begin");
+ if (ret == GST_STATE_CHANGE_FAILURE)
+ goto leave;
- g_omx_core_finish (self->gomx);
+ switch (transition)
+ {
+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
+ g_omx_port_pause (self->in_port);
+ break;
- g_omx_core_deinit (self->gomx);
- if (self->gomx->omx_error)
- return GST_STATE_CHANGE_FAILURE;
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ g_omx_core_finish (self->gomx);
+ break;
+ default:
+ break;
+ }
+
+leave:
GST_LOG_OBJECT (self, "end");
- return TRUE;
+ return ret;
}
static void
@@ -138,33 +154,12 @@ render (GstBaseSink *gst_base,
GST_LOG_OBJECT (self, "state: %d", gomx->omx_state);
- if (G_UNLIKELY (gomx->omx_state == OMX_StateLoaded))
- {
- GST_INFO_OBJECT (self, "omx: prepare");
-
- setup_ports (self);
- g_omx_core_prepare (self->gomx);
-
- self->ready = TRUE;
- }
-
in_port = self->in_port;
if (G_LIKELY (in_port->enabled))
{
guint buffer_offset = 0;
- if (G_UNLIKELY (gomx->omx_state == OMX_StateIdle))
- {
- GST_INFO_OBJECT (self, "omx: play");
- g_omx_core_start (gomx);
- }
-
- if (G_UNLIKELY (gomx->omx_state != OMX_StateExecuting))
- {
- GST_ERROR_OBJECT (self, "Whoa! very wrong");
- }
-
while (G_LIKELY (buffer_offset < GST_BUFFER_SIZE (buf)))
{
OMX_BUFFERHEADERTYPE *omx_buffer;
@@ -347,7 +342,6 @@ type_class_init (gpointer g_class,
gstelement_class->change_state = change_state;
- gst_base_sink_class->stop = stop;
gst_base_sink_class->event = handle_event;
gst_base_sink_class->preroll = render;
gst_base_sink_class->render = render;
@@ -382,31 +376,25 @@ activate_push (GstPad *pad,
{
GST_DEBUG_OBJECT (self, "activate");
- if (self->ready)
+ /* we do not start the task yet if the pad is not connected */
+ if (gst_pad_is_linked (pad))
{
- /* we do not start the task yet if the pad is not connected */
- if (gst_pad_is_linked (pad))
- {
- /** @todo link callback function also needed */
- g_omx_port_resume (self->in_port);
- }
+ /** @todo link callback function also needed */
+ g_omx_port_resume (self->in_port);
}
}
else
{
GST_DEBUG_OBJECT (self, "deactivate");
- if (self->ready)
- {
- /** @todo disable this until we properly reinitialize the buffers. */
+ /** @todo disable this until we properly reinitialize the buffers. */
#if 0
- /* flush all buffers */
- OMX_SendCommand (self->gomx->omx_handle, OMX_CommandFlush, OMX_ALL, NULL);
+ /* flush all buffers */
+ OMX_SendCommand (self->gomx->omx_handle, OMX_CommandFlush, OMX_ALL, NULL);
#endif
- /* unlock loops */
- g_omx_port_pause (self->in_port);
- }
+ /* unlock loops */
+ g_omx_port_pause (self->in_port);
}
gst_object_unref (self);
@@ -422,6 +410,8 @@ omx_init (GstOmxBaseSink *self)
if (self->gomx->omx_error)
return FALSE;
+ setup_ports (self);
+
return TRUE;
}
diff --git a/omx/gstomx_base_sink.h b/omx/gstomx_base_sink.h
index 1356cf7..564f380 100644
--- a/omx/gstomx_base_sink.h
+++ b/omx/gstomx_base_sink.h
@@ -49,7 +49,6 @@ struct GstOmxBaseSink
char *omx_component;
char *omx_library;
- gboolean ready;
gboolean initialized;
};
--
1.6.2.1.316.gedbc2
More information about the Gstreamer-openmax
mailing list