From 5125437606ba0b9c3e386fe282ac8e2d55f74042 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 23 Dec 2011 15:37:45 +0100 Subject: [PATCH] bufferpool: cleanup metadata in reset_buffer Use the reset_buffer vmethod to remove the unpooled metadata from the buffer. --- gst/gstbufferpool.c | 22 +++++++++++----------- gst/gstbufferpool.h | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gst/gstbufferpool.c b/gst/gstbufferpool.c index 07fbbf0d0d..4342b4a1e0 100644 --- a/gst/gstbufferpool.c +++ b/gst/gstbufferpool.c @@ -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)) diff --git a/gst/gstbufferpool.h b/gst/gstbufferpool.h index a05b84e01f..33b1cbe50a 100644 --- a/gst/gstbufferpool.h +++ b/gst/gstbufferpool.h @@ -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.