2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstbufferpool.c: Buffer-pool operations
|
2000-08-14 10:57:30 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstbuffer.h"
|
2000-08-14 10:57:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_buffer_pool_new:
|
|
|
|
*
|
|
|
|
* Create a new buffer pool.
|
|
|
|
*
|
|
|
|
* Returns: new buffer pool
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
GstBufferPool*
|
|
|
|
gst_buffer_pool_new (void)
|
2000-08-14 10:57:30 +00:00
|
|
|
{
|
|
|
|
GstBufferPool *pool;
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
pool = g_malloc (sizeof(GstBufferPool));
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"BUF: allocating new buffer pool %p\n", pool);
|
2000-08-14 10:57:30 +00:00
|
|
|
|
|
|
|
pool->new_buffer = NULL;
|
|
|
|
pool->destroy_buffer = NULL;
|
2000-11-11 15:13:50 +00:00
|
|
|
|
2000-08-14 10:57:30 +00:00
|
|
|
return pool;
|
|
|
|
}
|
|
|
|
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_pool_set_create_function:
|
|
|
|
* @pool: the pool to set the create function for
|
|
|
|
* @create: the create function
|
|
|
|
* @user_data: any user data to be passed in the create function
|
|
|
|
*
|
|
|
|
* Sets the function that will be called when a buffer is created
|
|
|
|
* from this pool.
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
void
|
|
|
|
gst_buffer_pool_set_create_function (GstBufferPool *pool,
|
|
|
|
GstBufferPoolCreateFunction create,
|
|
|
|
gpointer user_data)
|
2000-08-14 10:57:30 +00:00
|
|
|
{
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_if_fail (pool != NULL);
|
2000-08-14 10:57:30 +00:00
|
|
|
|
|
|
|
pool->new_buffer = create;
|
|
|
|
pool->new_user_data = user_data;
|
|
|
|
}
|
|
|
|
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_pool_set_destroy_function:
|
|
|
|
* @pool: the pool to set the destroy function for
|
|
|
|
* @destroy: the destroy function
|
|
|
|
* @user_data: any user data to be passed in the create function
|
|
|
|
*
|
|
|
|
* Sets the function that will be called when a buffer is destroyed
|
|
|
|
* from this pool.
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
void
|
|
|
|
gst_buffer_pool_set_destroy_function (GstBufferPool *pool,
|
|
|
|
GstBufferPoolDestroyFunction destroy,
|
|
|
|
gpointer user_data)
|
2000-08-14 10:57:30 +00:00
|
|
|
{
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_if_fail (pool != NULL);
|
2000-08-14 10:57:30 +00:00
|
|
|
|
|
|
|
pool->destroy_buffer = destroy;
|
|
|
|
pool->destroy_user_data = user_data;
|
|
|
|
}
|
|
|
|
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_pool_destroy:
|
|
|
|
* @pool: the pool to destroy
|
|
|
|
*
|
2001-01-06 22:05:15 +00:00
|
|
|
* Frees the memory for this bufferpool.
|
2000-10-25 19:09:53 +00:00
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
void
|
|
|
|
gst_buffer_pool_destroy (GstBufferPool *pool)
|
2000-08-14 10:57:30 +00:00
|
|
|
{
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_if_fail (pool != NULL);
|
2000-08-14 10:57:30 +00:00
|
|
|
|
|
|
|
g_free(pool);
|
|
|
|
}
|
|
|
|
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_pool_new_buffer:
|
|
|
|
* @pool: the pool to create the buffer from
|
|
|
|
*
|
2001-01-06 22:05:15 +00:00
|
|
|
* Uses the given pool to create a new buffer.
|
2000-10-25 19:09:53 +00:00
|
|
|
*
|
|
|
|
* Returns: The new buffer
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
GstBuffer*
|
|
|
|
gst_buffer_pool_new_buffer (GstBufferPool *pool)
|
2000-08-14 10:57:30 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_val_if_fail (pool != NULL, NULL);
|
2000-08-14 10:57:30 +00:00
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
buffer = pool->new_buffer (pool, pool->new_user_data);
|
2000-08-14 10:57:30 +00:00
|
|
|
buffer->pool = pool;
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_pool_destroy_buffer:
|
|
|
|
* @pool: the pool to return the buffer to
|
|
|
|
* @buffer: the buffer to return to the pool
|
|
|
|
*
|
|
|
|
* Gives a buffer back to the given pool.
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
void
|
|
|
|
gst_buffer_pool_destroy_buffer (GstBufferPool *pool,
|
|
|
|
GstBuffer *buffer)
|
2000-08-14 10:57:30 +00:00
|
|
|
{
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_if_fail (pool != NULL);
|
|
|
|
g_return_if_fail (buffer != NULL);
|
2000-08-14 10:57:30 +00:00
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
pool->destroy_buffer (pool, buffer, pool->new_user_data);
|
2000-08-14 10:57:30 +00:00
|
|
|
}
|