[Gstreamer-openmax] [PATCH] add some debug traces and asserts

Rob Clark rob at ti.com
Tue Nov 3 18:26:10 PST 2009


Signed-off-by: Rob Clark <rob at ti.com>
---
 omx/gstomx_base_filter.c |   18 ++++++++++++++++++
 omx/gstomx_util.c        |   11 ++++++++---
 omx/gstomx_util.h        |    8 ++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 35571ae..418915c 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -70,6 +70,7 @@ setup_ports (GstOmxBaseFilter *self)
 
     if (g_getenv ("OMX_ALLOCATE_ON"))
     {
+        GST_DEBUG_OBJECT (self, "OMX_ALLOCATE_ON");
         self->in_port->omx_allocate = TRUE;
         self->out_port->omx_allocate = TRUE;
         self->share_input_buffer = FALSE;
@@ -77,14 +78,25 @@ setup_ports (GstOmxBaseFilter *self)
     }
     else if (g_getenv ("OMX_SHARE_HACK_ON"))
     {
+        GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_ON");
         self->share_input_buffer = TRUE;
         self->share_output_buffer = TRUE;
     }
     else if (g_getenv ("OMX_SHARE_HACK_OFF"))
     {
+        GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_OFF");
         self->share_input_buffer = FALSE;
         self->share_output_buffer = FALSE;
     }
+    else
+    {
+        GST_DEBUG_OBJECT (self, "default sharing and allocation");
+    }
+
+    GST_DEBUG_OBJECT (self, "in_port->omx_allocate=%d, out_port->omx_allocate=%d",
+            self->in_port->omx_allocate, self->out_port->omx_allocate);
+    GST_DEBUG_OBJECT (self, "share_input_buffer=%d, share_output_buffer=%d",
+            self->share_input_buffer, self->share_output_buffer);
 }
 
 static GstStateChangeReturn
@@ -324,6 +336,8 @@ push_buffer (GstOmxBaseFilter *self,
 {
     GstFlowReturn ret;
 
+    PRINT_BUFFER (self, buf);
+
     /** @todo check if tainted */
     GST_LOG_OBJECT (self, "begin");
     ret = gst_pad_push (self->srcpad, buf);
@@ -407,6 +421,8 @@ output_loop (gpointer data)
             /* buf is always null when the output buffer pointer isn't shared. */
             buf = omx_buffer->pAppPrivate;
 
+            PRINT_BUFFER (self, buf);
+
             /** @todo we need to move all the caps handling to one single
              * place, in the output loop probably. */
             if (G_UNLIKELY (omx_buffer->nFlags & 0x80))
@@ -571,6 +587,8 @@ pad_chain (GstPad *pad,
 
     self = GST_OMX_BASE_FILTER (GST_OBJECT_PARENT (pad));
 
+    PRINT_BUFFER (self, buf);
+
     gomx = self->gomx;
 
     GST_LOG_OBJECT (self, "begin");
diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
index 1cd224f..2bd25b4 100644
--- a/omx/gstomx_util.c
+++ b/omx/gstomx_util.c
@@ -358,14 +358,16 @@ g_omx_core_init (GOmxCore *core)
                                                        core,
                                                        &callbacks);
 
+    g_free (component_name);
+    g_free (library_name);
+
     GST_DEBUG_OBJECT (core->object, "OMX_GetHandle(&%p) -> %d",
         core->omx_handle, core->omx_error);
 
+    g_return_if_fail (core->omx_handle);
+
     if (!core->omx_error)
         core->omx_state = OMX_StateLoaded;
-
-    g_free (component_name);
-    g_free (library_name);
 }
 
 void
@@ -509,6 +511,7 @@ OMX_HANDLETYPE
 g_omx_core_get_handle (GOmxCore *core)
 {
   if (!core->omx_handle) g_omx_core_init (core);
+  g_return_val_if_fail (core->omx_handle, NULL);
   return core->omx_handle;
 }
 
@@ -589,6 +592,7 @@ port_allocate_buffers (GOmxPort *port)
     {
         if (port->omx_allocate)
         {
+            GST_DEBUG_OBJECT (port->core->object, "%d: OMX_AllocateBuffer(), size=%d", i, size);
             OMX_AllocateBuffer (port->core->omx_handle,
                                 &port->buffers[i],
                                 port->port_index,
@@ -599,6 +603,7 @@ port_allocate_buffers (GOmxPort *port)
         {
             gpointer buffer_data;
             buffer_data = g_malloc (size);
+            GST_DEBUG_OBJECT (port->core->object, "%d: OMX_UseBuffer(), size=%d", i, size);
             OMX_UseBuffer (port->core->omx_handle,
                            &port->buffers[i],
                            port->port_index,
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index be9290f..6627a49 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -198,5 +198,13 @@ void g_omx_port_finish (GOmxPort *port);
         OMX_SetConfig (                                                       \
             g_omx_core_get_handle ((port)->core), idx, (param))
 
+#define PRINT_BUFFER(obj, buffer)    G_STMT_START {             \
+    if (buffer) {                                               \
+      GST_DEBUG_OBJECT (obj, #buffer "=0x%08x (time=%"GST_TIME_FORMAT", duration=%"GST_TIME_FORMAT", flags=%08x)", (buffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)), GST_TIME_ARGS (GST_BUFFER_DURATION(buffer)), GST_BUFFER_FLAGS (buffer)); \
+    } else {                                                    \
+      GST_DEBUG_OBJECT (obj, #buffer "=null");                  \
+    }                                                           \
+  } G_STMT_END
+
 
 #endif /* GSTOMX_UTIL_H */
-- 
1.6.3.2





More information about the Gstreamer-openmax mailing list