[Gstreamer-openmax] [PATCH 1/8] core: call OMX_GetHandle in g_omx_core_new
Rob Clark
rob at ti.com
Wed Mar 17 16:58:54 PDT 2010
This way omx_handle is always valid, and can be used in get/set_property
methods.
---
omx/gstomx_base_filter.c | 8 +-------
omx/gstomx_base_sink.c | 5 +----
omx/gstomx_base_src.c | 5 +----
omx/gstomx_util.c | 23 ++++++++++++++++++-----
omx/gstomx_util.h | 4 +---
5 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index e12fcd2..871c395 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -101,7 +101,6 @@ change_state (GstElement *element,
switch (transition)
{
case GST_STATE_CHANGE_NULL_TO_READY:
- g_omx_core_init (core);
if (core->omx_state != OMX_StateLoaded)
{
ret = GST_STATE_CHANGE_FAILURE;
@@ -141,10 +140,6 @@ change_state (GstElement *element,
}
break;
- case GST_STATE_CHANGE_READY_TO_NULL:
- g_omx_core_deinit (core);
- break;
-
default:
break;
}
@@ -875,8 +870,7 @@ type_instance_init (GTypeInstance *instance,
self->use_timestamps = TRUE;
- self->gomx = g_omx_core_new (self);
- gstomx_get_component_info (self->gomx, G_TYPE_FROM_CLASS (g_class));
+ self->gomx = g_omx_core_new (self, g_class);
self->in_port = g_omx_core_new_port (self->gomx, 0);
self->out_port = g_omx_core_new_port (self->gomx, 1);
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index b6a8955..e78db32 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -381,8 +381,6 @@ activate_push (GstPad *pad,
static inline gboolean
omx_init (GstOmxBaseSink *self)
{
- g_omx_core_init (self->gomx);
-
if (self->gomx->omx_error)
return FALSE;
@@ -421,8 +419,7 @@ type_instance_init (GTypeInstance *instance,
GST_LOG_OBJECT (self, "begin");
- self->gomx = g_omx_core_new (self);
- gstomx_get_component_info (self->gomx, G_TYPE_FROM_CLASS (g_class));
+ self->gomx = g_omx_core_new (self, g_class);
self->in_port = g_omx_core_new_port (self->gomx, 0);
{
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index fea7631..888a447 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -54,7 +54,6 @@ start (GstBaseSrc *gst_base)
GST_LOG_OBJECT (self, "begin");
- g_omx_core_init (self->gomx);
if (self->gomx->omx_error)
return GST_STATE_CHANGE_FAILURE;
@@ -74,7 +73,6 @@ stop (GstBaseSrc *gst_base)
g_omx_core_stop (self->gomx);
g_omx_core_unload (self->gomx);
- g_omx_core_deinit (self->gomx);
if (self->gomx->omx_error)
return GST_STATE_CHANGE_FAILURE;
@@ -406,8 +404,7 @@ type_instance_init (GTypeInstance *instance,
GST_LOG_OBJECT (self, "begin");
- self->gomx = g_omx_core_new (self);
- gstomx_get_component_info (self->gomx, G_TYPE_FROM_CLASS (g_class));
+ self->gomx = g_omx_core_new (self, g_class);
self->out_port = g_omx_core_new_port (self->gomx, 1);
GST_LOG_OBJECT (self, "end");
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index b1c869a..115ca84 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -79,6 +79,9 @@ omx_error_to_str (OMX_ERRORTYPE omx_error);
static inline GOmxPort * get_port (GOmxCore *core, guint index);
+static void core_init (GOmxCore *core);
+static void core_deinit (GOmxCore *core);
+
static inline void
port_free_buffers (GOmxPort *port);
@@ -264,7 +267,7 @@ g_omx_deinit (void)
*/
GOmxCore *
-g_omx_core_new (void *object)
+g_omx_core_new (void *object, gpointer g_class)
{
GOmxCore *core;
@@ -282,12 +285,22 @@ g_omx_core_new (void *object)
core->omx_state = OMX_StateInvalid;
+ /* it is a bit awkward to have to pass the element's g_class to
+ * g_omx_core_new(), but since this is called from type_inistance_init
+ * function, we can't rely on G_OBJECT_TYPE()..
+ */
+ gstomx_get_component_info (core, G_TYPE_FROM_CLASS (g_class));
+
+ core_init (core);
+
return core;
}
void
g_omx_core_free (GOmxCore *core)
{
+ core_deinit (core);
+
g_sem_free (core->port_sem);
g_sem_free (core->flush_sem);
g_sem_free (core->done_sem);
@@ -300,8 +313,8 @@ g_omx_core_free (GOmxCore *core)
g_free (core);
}
-void
-g_omx_core_init (GOmxCore *core)
+static void
+core_init (GOmxCore *core)
{
core->imp = request_imp (core->library_name);
@@ -316,8 +329,8 @@ g_omx_core_init (GOmxCore *core)
core->omx_state = OMX_StateLoaded;
}
-void
-g_omx_core_deinit (GOmxCore *core)
+static void
+core_deinit (GOmxCore *core)
{
if (!core->imp)
return;
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index 456f9a8..d373193 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -117,10 +117,8 @@ struct GOmxPort
void g_omx_init (void);
void g_omx_deinit (void);
-GOmxCore *g_omx_core_new (void *object);
+GOmxCore *g_omx_core_new (void *object, gpointer g_class);
void g_omx_core_free (GOmxCore *core);
-void g_omx_core_init (GOmxCore *core);
-void g_omx_core_deinit (GOmxCore *core);
void g_omx_core_prepare (GOmxCore *core);
void g_omx_core_start (GOmxCore *core);
void g_omx_core_pause (GOmxCore *core);
--
1.6.3.2
More information about the Gstreamer-openmax
mailing list