[Gstreamer-openmax] [PATCH 03/10] add accessor for OMX_HANDLE
Rob Clark
rob at ti.com
Sun Mar 7 15:14:50 PST 2010
A method for GOmxCore object which can be called at any time to access OMX component handle. If the OMX component is not yet instantiated, this will
trigger OMX_GetHandle(). This makes it safe to use in places like get/set_property methods which could be called before the OMX component would otherwise
be instantiated.
---
omx/gstomx_util.c | 29 ++++++++++++++++++++++++++++-
omx/gstomx_util.h | 1 +
2 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index d8cc7f0..efe953d 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -287,6 +287,8 @@ g_omx_core_new (void *object)
void
g_omx_core_free (GOmxCore *core)
{
+ g_omx_core_deinit (core); /* just in case we didn't have a READY->NULL.. mainly for gst-inspect */
+
g_sem_free (core->port_sem);
g_sem_free (core->flush_sem);
g_sem_free (core->done_sem);
@@ -302,6 +304,9 @@ g_omx_core_free (GOmxCore *core)
void
g_omx_core_init (GOmxCore *core)
{
+ if (core->omx_handle)
+ return;
+
core->imp = request_imp (core->library_name);
if (!core->imp)
@@ -318,14 +323,21 @@ g_omx_core_init (GOmxCore *core)
void
g_omx_core_deinit (GOmxCore *core)
{
- if (!core->imp)
+ if (!core->imp || !core->omx_handle)
return;
if (core->omx_state == OMX_StateLoaded ||
core->omx_state == OMX_StateInvalid)
{
if (core->omx_handle)
+ {
core->omx_error = core->imp->sym_table.free_handle (core->omx_handle);
+ core->omx_handle = NULL;
+ }
+ }
+ else
+ {
+ GST_WARNING ("incorrect state: %s", omx_state_to_str (core->omx_state));
}
g_free (core->library_name);
@@ -445,6 +457,21 @@ g_omx_core_flush_stop (GOmxCore *core)
core_for_each_port (core, g_omx_port_resume);
}
+/**
+ * Accessor for OMX component handle. If the OMX component is not constructed
+ * yet, this will trigger it to be constructed (OMX_GetHandle()). This should
+ * at least be used in places where g_omx_core_init() might not have been
+ * called yet (such as setting/getting properties)
+ */
+OMX_HANDLETYPE
+g_omx_core_get_handle (GOmxCore *core)
+{
+ if (!core->omx_handle)
+ g_omx_core_init (core);
+ return core->omx_handle;
+}
+
+
/*
* Port
*/
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index 060b042..404df8a 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -130,6 +130,7 @@ void g_omx_core_set_done (GOmxCore *core);
void g_omx_core_wait_for_done (GOmxCore *core);
void g_omx_core_flush_start (GOmxCore *core);
void g_omx_core_flush_stop (GOmxCore *core);
+OMX_HANDLETYPE g_omx_core_get_handle (GOmxCore *core);
GOmxPort *g_omx_core_get_port (GOmxCore *core, guint index);
GOmxPort *g_omx_port_new (GOmxCore *core, guint index);
--
1.6.3.2
More information about the Gstreamer-openmax
mailing list