omx: factor out gst_omx_buffer_reset()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 4 Oct 2017 15:11:55 +0000 (17:11 +0200)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 11 Oct 2017 17:51:55 +0000 (13:51 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=788711

omx/gstomx.c

index 5093103..fb147ee 100644 (file)
@@ -225,6 +225,14 @@ gst_omx_component_flush_messages (GstOMXComponent * comp)
   g_mutex_unlock (&comp->messages_lock);
 }
 
+static void
+gst_omx_buffer_reset (GstOMXBuffer * buf)
+{
+  buf->omx_buf->nFlags = 0;
+  buf->omx_buf->nOffset = 0;
+  buf->omx_buf->nFilledLen = 0;
+}
+
 /* NOTE: Call with comp->lock, comp->messages_lock will be used */
 static void
 gst_omx_component_handle_messages (GstOMXComponent * comp)
@@ -372,15 +380,11 @@ gst_omx_component_handle_messages (GstOMXComponent * comp)
               "%s port %u emptied buffer %p (%p)", port->comp->name,
               port->index, buf, buf->omx_buf->pBuffer);
 
-          /* Reset offset and filled length */
-          buf->omx_buf->nOffset = 0;
-          buf->omx_buf->nFilledLen = 0;
-
           /* Reset all flags, some implementations don't
            * reset them themselves and the flags are not
            * valid anymore after the buffer was consumed
            */
-          buf->omx_buf->nFlags = 0;
+          gst_omx_buffer_reset (buf);
         } else {
           /* Output buffer contains output now or
            * the port was flushed */
@@ -1438,11 +1442,7 @@ gst_omx_port_release_buffer (GstOMXPort * port, GstOMXBuffer * buf)
      * reset them themselves and the flags are not
      * valid anymore after the buffer was consumed
      */
-    buf->omx_buf->nFlags = 0;
-
-    /* Reset offset and filled length */
-    buf->omx_buf->nOffset = 0;
-    buf->omx_buf->nFilledLen = 0;
+    gst_omx_buffer_reset (buf);
   }
 
   if ((err = comp->last_error) != OMX_ErrorNone) {
@@ -2094,8 +2094,7 @@ gst_omx_port_populate_unlocked (GstOMXPort * port)
        * valid anymore after the buffer was consumed.
        * Also reset nFilledLen as FillThisBuffer() expects an empty buffer.
        */
-      buf->omx_buf->nFlags = 0;
-      buf->omx_buf->nFilledLen = 0;
+      gst_omx_buffer_reset (buf);
 
       err = OMX_FillThisBuffer (comp->handle, buf->omx_buf);