bufferpool: Reset the buffer before releasing into pool

Reset the buffer not after we acquire but before we release into the pool. This
makes sure that the pool only has buffers in a clean state and that we can set
extra metadata on buffers in the acquire method. this means that we need to
remove an argument from the method.
This commit is contained in:
Wim Taymans 2012-04-25 09:06:05 +02:00
parent db59375785
commit b67be761e0
2 changed files with 7 additions and 9 deletions

View file

@ -130,8 +130,7 @@ static GstFlowReturn default_alloc_buffer (GstBufferPool * pool,
GstBuffer ** buffer, GstBufferPoolAcquireParams * params);
static GstFlowReturn default_acquire_buffer (GstBufferPool * pool,
GstBuffer ** buffer, GstBufferPoolAcquireParams * params);
static void default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer,
GstBufferPoolAcquireParams * params);
static void default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer);
static void default_free_buffer (GstBufferPool * pool, GstBuffer * buffer);
static void default_release_buffer (GstBufferPool * pool, GstBuffer * buffer);
@ -997,8 +996,7 @@ remove_meta_unpooled (GstBuffer * buffer, GstMeta ** meta, gpointer user_data)
}
static void
default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer,
GstBufferPoolAcquireParams * params)
default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer)
{
GST_BUFFER_FLAGS (buffer) = 0;
@ -1051,9 +1049,6 @@ gst_buffer_pool_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
/* all buffers from the pool point to the pool and have the refcount of the
* pool incremented */
(*buffer)->pool = gst_object_ref (pool);
/* now reset the buffer when needed */
if (G_LIKELY (pclass->reset_buffer))
pclass->reset_buffer (pool, *buffer, params);
} else {
dec_outstanding (pool);
}
@ -1096,6 +1091,10 @@ gst_buffer_pool_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
pclass = GST_BUFFER_POOL_GET_CLASS (pool);
/* reset the buffer when needed */
if (G_LIKELY (pclass->reset_buffer))
pclass->reset_buffer (pool, buffer);
if (G_LIKELY (pclass->release_buffer))
pclass->release_buffer (pool, buffer);

View file

@ -156,8 +156,7 @@ struct _GstBufferPoolClass {
GstBufferPoolAcquireParams *params);
GstFlowReturn (*alloc_buffer) (GstBufferPool *pool, GstBuffer **buffer,
GstBufferPoolAcquireParams *params);
void (*reset_buffer) (GstBufferPool *pool, GstBuffer *buffer,
GstBufferPoolAcquireParams *params);
void (*reset_buffer) (GstBufferPool *pool, GstBuffer *buffer);
void (*release_buffer) (GstBufferPool *pool, GstBuffer *buffer);
void (*free_buffer) (GstBufferPool *pool, GstBuffer *buffer);