Browse files

core: call OMX_GetHandle in g_omx_core_new

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

Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
  • Loading branch information...
1 parent 83f24be commit 034c1dac8f8a6bcc67f388ce3e8f6f0b4f77c178 Rob Clark committed with Felipe Contreras Mar 29, 2010
Showing with 20 additions and 18 deletions.
  1. +9 −0 omx/gstomx.c
  2. +2 −0 omx/gstomx.h
  3. +1 −7 omx/gstomx_base_filter.c
  4. +1 −4 omx/gstomx_base_sink.c
  5. +1 −4 omx/gstomx_base_src.c
  6. +6 −2 omx/gstomx_util.c
  7. +0 −1 omx/gstomx_util.h
View
9 omx/gstomx.c
@@ -333,6 +333,15 @@ gstomx_get_component_info (void *core,
return TRUE;
}
+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",
View
2 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 */
View
8 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);
View
5 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);
{
View
5 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");
View
8 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;
View
1 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);

0 comments on commit 034c1da

Please sign in to comment.