bufferpool: cleanup metadata in reset_buffer
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 23 Dec 2011 14:37:45 +0000 (15:37 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 23 Dec 2011 14:37:45 +0000 (15:37 +0100)
Use the reset_buffer vmethod to remove the unpooled metadata from the buffer.

gst/gstbufferpool.c
gst/gstbufferpool.h

index 07fbbf0..4342b4a 100644 (file)
@@ -861,6 +861,14 @@ dec_outstanding (GstBufferPool * pool)
   }
 }
 
+static gboolean
+remove_meta_unpooled (GstBuffer * buffer, GstMeta ** meta, gpointer user_data)
+{
+  if (!GST_META_FLAG_IS_SET (*meta, GST_META_FLAG_POOLED))
+    *meta = NULL;
+  return TRUE;
+}
+
 static void
 default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer,
     GstBufferPoolParams * params)
@@ -872,6 +880,9 @@ default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer,
   GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
   GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE;
   GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE;
+
+  /* remove all metadata without the POOLED flag */
+  gst_buffer_foreach_meta (buffer, remove_meta_unpooled, pool);
 }
 
 /**
@@ -932,14 +943,6 @@ default_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
   gst_poll_write_control (pool->poll);
 }
 
-static gboolean
-remove_meta_unpooled (GstBuffer * buffer, GstMeta ** meta, gpointer user_data)
-{
-  if (!GST_META_FLAG_IS_SET (*meta, GST_META_FLAG_POOLED))
-    *meta = NULL;
-  return TRUE;
-}
-
 /**
  * gst_buffer_pool_release_buffer:
  * @pool: a #GstBufferPool
@@ -964,9 +967,6 @@ gst_buffer_pool_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
   if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&buffer->pool, pool, NULL))
     return;
 
-  /* remove all metadata without the POOLED flag */
-  gst_buffer_foreach_meta (buffer, remove_meta_unpooled, pool);
-
   pclass = GST_BUFFER_POOL_GET_CLASS (pool);
 
   if (G_LIKELY (pclass->release_buffer))
index a05b84e..33b1cbe 100644 (file)
@@ -147,7 +147,8 @@ struct _GstBufferPool {
  *        buffers from the default memory allocator and with the configured
  *        size, prefix and alignment.
  * @reset_buffer: reset the buffer to its state when it was freshly allocated.
- *        The default implementation will clear the flags and timestamps.
+ *        The default implementation will clear the flags, timestamps and
+ *        will remove the metadata added after alloc_buffer.
  * @release_buffer: release a buffer back in the pool. The default
  *        implementation will put the buffer back in the queue and notify any
  *        blocking acquire_buffer calls.