[Gstreamer-openmax] [PATCH 1/8] core: call OMX_GetHandle in g_omx_core_new

Rob Clark rob at ti.com
Mon Mar 29 06:05:39 PDT 2010


This way omx_handle is always valid, and can be used in get/set_property
methods.
---

v2: add gstomx_core_new() which calls g_omx_core_new(),
gstomx_get_component_info(), and then g_omx_core_init() to avoid a
dependencies on gstomx from g_omx

 omx/gstomx.c             |   13 +++++++++++++
 omx/gstomx.h             |    2 ++
 omx/gstomx_base_filter.c |    8 +-------
 omx/gstomx_base_sink.c   |    5 +----
 omx/gstomx_base_src.c    |    5 +----
 omx/gstomx_util.c        |    8 ++++++--
 omx/gstomx_util.h        |    1 -
 7 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/omx/gstomx.c b/omx/gstomx.c
index ff232b0..2a3a0b7 100644
--- a/omx/gstomx.c
+++ b/omx/gstomx.c
@@ -333,6 +333,19 @@ gstomx_get_component_info (void *core,
     return TRUE;
 }
 
+/* for now, to keep gst out of g_omx.. if later g_omx becomes gstomx
+ * then this could be combined with the existing g_omx_core_new()
+ * and g_omx_core_init() could be made static/private
+ */
+void *
+gstomx_core_new (void *object, GType type)
+{
+    GOmxCore *core = g_omx_core_new (object);
+    gstomx_get_component_info (core, type);
+    g_omx_core_init (core);
+    return core;
+}
+
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
                    GST_VERSION_MINOR,
                    "omx",
diff --git a/omx/gstomx.h b/omx/gstomx.h
index b62773c..4f07fd6 100644
--- a/omx/gstomx.h
+++ b/omx/gstomx.h
@@ -33,6 +33,8 @@ GST_DEBUG_CATEGORY_EXTERN (gstomx_util_debug);
 gboolean gstomx_get_component_info (void *core,
                                     GType type);
 
+void * gstomx_core_new (void *object, GType type);
+
 G_END_DECLS
 
 #endif /* GSTOMX_H */
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index e12fcd2..019b52b 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 = gstomx_core_new (self, G_TYPE_FROM_CLASS (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..f3e116f 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 = gstomx_core_new (self, G_TYPE_FROM_CLASS (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..49ddd54 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 = gstomx_core_new (self, G_TYPE_FROM_CLASS (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..59e6487 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -79,6 +79,8 @@ omx_error_to_str (OMX_ERRORTYPE omx_error);
 
 static inline GOmxPort * get_port (GOmxCore *core, guint index);
 
+static void core_deinit (GOmxCore *core);
+
 static inline void
 port_free_buffers (GOmxPort *port);
 
@@ -288,6 +290,8 @@ g_omx_core_new (void *object)
 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);
@@ -316,8 +320,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..5c928ed 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -120,7 +120,6 @@ void g_omx_deinit (void);
 GOmxCore *g_omx_core_new (void *object);
 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.6





More information about the Gstreamer-openmax mailing list