bufferpool: cleanup metadata in reset_buffer

Use the reset_buffer vmethod to remove the unpooled metadata from the buffer.
This commit is contained in:
Wim Taymans 2011-12-23 15:37:45 +01:00
parent c335a7a324
commit 5125437606
2 changed files with 13 additions and 12 deletions

View 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))

View 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.