Commit fcb10a6c authored by Wim Taymans's avatar Wim Taymans

- Removed bufferpool code and move that to gstbuffer.c

Original commit message from CVS:
- Removed bufferpool code and move that to gstbuffer.c
- implemented refcounting on GstData
- implemented new buffer code based on Company's work in the EVENTS2 branch
- added boxed types for GstData/GstEvent/GstBuffer/GstBufferPool
- added refcounting to bufferpools and events
- use lockfree allocation for buffers
- simplified the clock, use lockfree allocation
- use GQueue in GstQueue for faster access to the tail element
- update core plugins to the new event API
parent 74b6b732
......@@ -55,15 +55,16 @@ libgstreamer_la_SOURCES = \
$(GST_AUTOPLUG_SRC) \
gstbin.c \
gstbuffer.c \
gstbufferpool.c \
gstcaps.c \
gstclock.c \
gstcpu.c \
gstdata.c \
gstelement.c \
gstelementfactory.c \
gstevent.c \
gstextratypes.c \
gstinfo.c \
gstmemchunk.c \
gstpad.c \
gstpipeline.c \
gstplugin.c \
......@@ -125,6 +126,7 @@ distclean-local:
libgstreamerincludedir = $(includedir)/gstreamer-@VERSION@/gst
libgstreamerinclude_HEADERS = \
gst.h \
gstatomic.h \
gstconfig.h \
gstmarshal.h \
gstenumtypes.h \
......@@ -133,7 +135,6 @@ libgstreamerinclude_HEADERS = \
gstautoplug.h \
gstbin.h \
gstbuffer.h \
gstbufferpool.h \
gstcaps.h \
gstclock.h \
gstcpu.h \
......@@ -144,6 +145,7 @@ libgstreamerinclude_HEADERS = \
gstformat.h \
gstinfo.h \
gstlog.h \
gstmemchunk.h \
gstpad.h \
gstpipeline.h \
gstplugin.h \
......
......@@ -266,8 +266,6 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
gst_pad_event_default (pad, event);
break;
}
gst_event_free (event);
return;
}
......
......@@ -323,7 +323,6 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event)
src->buffer_count = GST_EVENT_SEEK_OFFSET (event);
if (!GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
gst_event_free (event);
break;
}
/* else we do a flush too */
......@@ -333,6 +332,7 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event)
default:
break;
}
gst_event_unref (event);
return TRUE;
}
......@@ -680,8 +680,8 @@ gst_fakesrc_get(GstPad *pad)
if (src->last_message)
g_free (src->last_message);
src->last_message = g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %llu)",
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
src->last_message = g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %llu) %p",
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_object_notify (G_OBJECT (src), "last_message");
}
......
......@@ -304,7 +304,7 @@ gst_filesink_handle_event (GstPad *pad, GstEvent *event)
if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &offset))
fseek(filesink->file, offset, SEEK_SET);
gst_event_free (event);
gst_event_unref (event);
break;
}
case GST_EVENT_NEW_MEDIA:
......
......@@ -337,6 +337,10 @@ gst_filesrc_free_parent_mmap (GstBuffer *buf)
#endif
/* now unmap the memory */
munmap(GST_BUFFER_DATA(buf),GST_BUFFER_MAXSIZE(buf));
GST_BUFFER_DATA (buf) = NULL;
_gst_buffer_free (buf);
}
static GstBuffer *
......@@ -371,7 +375,7 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
GST_BUFFER_OFFSET(buf) = offset;
GST_BUFFER_TIMESTAMP(buf) = -1LL;
GST_BUFFER_POOL_PRIVATE(buf) = src;
GST_BUFFER_FREE_FUNC(buf) = gst_filesrc_free_parent_mmap;
GST_BUFFER_FREE_FUNC(buf) = (GstDataFreeFunction) gst_filesrc_free_parent_mmap;
g_mutex_lock(src->map_regions_lock);
g_tree_insert(src->map_regions,buf,buf);
......@@ -716,7 +720,7 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
guint64 offset;
if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_BYTES) {
return FALSE;
goto error;
}
offset = GST_EVENT_SEEK_OFFSET (event);
......@@ -724,24 +728,24 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
if (offset > src->filelen)
return FALSE;
goto error;
src->curoffset = offset;
GST_DEBUG(0, "seek set pending to %lld", src->curoffset);
break;
case GST_SEEK_METHOD_CUR:
if (offset + src->curoffset > src->filelen)
return FALSE;
goto error;
src->curoffset += offset;
GST_DEBUG(0, "seek cur pending to %lld", src->curoffset);
break;
case GST_SEEK_METHOD_END:
if (ABS (offset) > src->filelen)
return FALSE;
goto error;
src->curoffset = src->filelen - ABS (offset);
GST_DEBUG(0, "seek end pending to %lld", src->curoffset);
break;
default:
return FALSE;
goto error;
break;
}
g_object_notify (G_OBJECT (src), "offset");
......@@ -751,7 +755,7 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
}
case GST_EVENT_SIZE:
if (GST_EVENT_SIZE_FORMAT (event) != GST_FORMAT_BYTES) {
return FALSE;
goto error;
}
src->block_size = GST_EVENT_SIZE_VALUE (event);
g_object_notify (G_OBJECT (src), "blocksize");
......@@ -760,9 +764,13 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
src->need_flush = TRUE;
break;
default:
return FALSE;
goto error;
break;
}
gst_event_unref (event);
return TRUE;
error:
gst_event_unref (event);
return FALSE;
}
......@@ -377,7 +377,6 @@ init_post (void)
_gst_plugin_initialize ();
_gst_event_initialize ();
_gst_buffer_initialize ();
_gst_buffer_pool_initialize ();
if (!_gst_registry_fixed) {
/* don't override command-line options */
......
This diff is collapsed.
......@@ -24,153 +24,150 @@
#ifndef __GST_BUFFER_H__
#define __GST_BUFFER_H__
/*
* Define this to add file:line info to each GstBuffer showing
* the location in the source code where the buffer was created.
*
* #define GST_BUFFER_WHERE
*
* Then in gdb, you can `call gst_buffer_print_live()' to get a list
* of allocated GstBuffers and also the file:line where they were
* allocated.
*/
#include <gst/gstdata.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_ATOMIC_H
#include <asm/atomic.h>
#endif
G_BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GstBuffer GstBuffer;
typedef struct _GstBufferPool GstBufferPool;
extern GType _gst_buffer_type;
#define GST_TYPE_BUFFER (_gst_buffer_type)
#define GST_BUFFER(buf) ((GstBuffer *)(buf))
#define GST_IS_BUFFER(buf) (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER)
#define GST_BUFFER_FLAGS(buf) (GST_BUFFER(buf)->flags)
#define GST_BUFFER_FLAG_IS_SET(buf,flag) (GST_BUFFER_FLAGS(buf) & (1<<(flag)))
#define GST_BUFFER_FLAG_SET(buf,flag) G_STMT_START{ (GST_BUFFER_FLAGS(buf) |= (1<<(flag))); }G_STMT_END
#define GST_BUFFER_FLAG_UNSET(buf,flag) G_STMT_START{ (GST_BUFFER_FLAGS(buf) &= ~(1<<(flag))); }G_STMT_END
#define GST_BUFFER_DATA(buf) (GST_BUFFER(buf)->data)
#define GST_BUFFER_SIZE(buf) (GST_BUFFER(buf)->size)
#define GST_BUFFER_OFFSET(buf) (GST_BUFFER(buf)->offset)
#define GST_BUFFER_MAXSIZE(buf) (GST_BUFFER(buf)->maxsize)
#define GST_BUFFER_TIMESTAMP(buf) (GST_BUFFER(buf)->timestamp)
#define GST_BUFFER_MAXAGE(buf) (GST_BUFFER(buf)->maxage)
#define GST_BUFFER_BUFFERPOOL(buf) (GST_BUFFER(buf)->pool)
#define GST_BUFFER_PARENT(buf) (GST_BUFFER(buf)->parent)
#define GST_BUFFER_POOL_PRIVATE(buf) (GST_BUFFER(buf)->pool_private)
#define GST_BUFFER_COPY_FUNC(buf) (GST_BUFFER(buf)->copy)
#define GST_BUFFER_FREE_FUNC(buf) (GST_BUFFER(buf)->free)
#define GST_BUFFER_LOCK(buf) (g_mutex_lock(GST_BUFFER(buf)->lock))
#define GST_BUFFER_TRYLOCK(buf) (g_mutex_trylock(GST_BUFFER(buf)->lock))
#define GST_BUFFER_UNLOCK(buf) (g_mutex_unlock(GST_BUFFER(buf)->lock))
typedef enum {
GST_BUFFER_READONLY,
extern GType _gst_buffer_pool_type;
#define GST_TYPE_BUFFER (_gst_buffer_type)
#define GST_TYPE_BUFFER_POOL (_gst_buffer_pool_type)
#define GST_BUFFER(buf) ((GstBuffer *)(buf))
#define GST_BUFFER_POOL(pool) ((GstBufferPool *)(pool))
#define GST_IS_BUFFER(buf) (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER)
#define GST_IS_BUFFER_POOL(buf) (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER_POOL)
#define GST_BUFFER_REFCOUNT(buf) GST_DATA_REFCOUNT(buf)
#define GST_BUFFER_REFCOUNT_VALUE(buf) GST_DATA_REFCOUNT_VALUE(buf)
#define GST_BUFFER_COPY_FUNC(buf) GST_DATA_COPY_FUNC(buf)
#define GST_BUFFER_FREE_FUNC(buf) GST_DATA_FREE_FUNC(buf)
#define GST_BUFFER_FLAGS(buf) GST_DATA_FLAGS(buf)
#define GST_BUFFER_FLAG_IS_SET(buf,flag) GST_DATA_FLAG_IS_SET (buf, flag)
#define GST_BUFFER_FLAG_SET(buf,flag) GST_DATA_FLAG_SET (buf, flag)
#define GST_BUFFER_FLAG_UNSET(buf,flag) GST_DATA_FLAG_UNSET (buf, flag)
#define GST_BUFFER_DATA(buf) (GST_BUFFER(buf)->data)
#define GST_BUFFER_SIZE(buf) (GST_BUFFER(buf)->size)
#define GST_BUFFER_MAXSIZE(buf) (GST_BUFFER(buf)->maxsize)
#define GST_BUFFER_TIMESTAMP(buf) (GST_BUFFER(buf)->timestamp)
#define GST_BUFFER_OFFSET(buf) (GST_BUFFER(buf)->offset)
#define GST_BUFFER_BUFFERPOOL(buf) (GST_BUFFER(buf)->pool)
#define GST_BUFFER_POOL_PRIVATE(buf) (GST_BUFFER(buf)->pool_private)
enum {
GST_BUFFER_READONLY = GST_DATA_FLAG_LAST,
GST_BUFFER_SUBBUFFER,
GST_BUFFER_ORIGINAL,
GST_BUFFER_DONTFREE,
GST_BUFFER_DISCONTINOUS,
GST_BUFFER_KEY_UNIT,
GST_BUFFER_PREROLL,
} GstBufferFlag;
typedef struct _GstBuffer GstBuffer;
GST_BUFFER_FLAG_LAST = GST_DATA_FLAG_LAST + 8,
};
typedef void (*GstBufferFreeFunc) (GstBuffer *buf);
typedef GstBuffer *(*GstBufferCopyFunc) (GstBuffer *srcbuf);
struct _GstBuffer {
GstData data_type;
/* pointer to data and its size */
guint8 *data; /* pointer to buffer data */
guint size; /* size of buffer data */
guint64 maxsize; /* max size of this buffer */
#include <gst/gstbufferpool.h>
guint64 timestamp;
guint64 offset;
struct _GstBuffer {
GstData data_type;
/* this is a pointer to the buffer pool (if any) */
GstBufferPool *pool;
/* pointer to pool private data of parent buffer in case of a subbuffer */
gpointer pool_private;
};
/* locking */
GMutex *lock;
/* bufferpools */
/* refcounting */
#ifdef HAVE_ATOMIC_H
atomic_t refcount;
#define GST_BUFFER_REFCOUNT(buf) (atomic_read(&(GST_BUFFER((buf))->refcount)))
#else
int refcount;
#define GST_BUFFER_REFCOUNT(buf) (GST_BUFFER(buf)->refcount)
#endif
typedef GstBuffer* (*GstBufferPoolBufferNewFunction) (GstBufferPool *pool, guint64 offset, guint size, gpointer user_data);
typedef GstBuffer* (*GstBufferPoolBufferCopyFunction) (GstBufferPool *pool, const GstBuffer *buffer, gpointer user_data);
typedef void (*GstBufferPoolBufferFreeFunction) (GstBufferPool *pool, GstBuffer *buffer, gpointer user_data);
/* flags */
guint16 flags; /* boolean properties of buffer */
struct _GstBufferPool {
GstData data;
/* pointer to data, its size, and offset in original source if known */
guchar *data;
guint32 size;
guint32 maxsize;
guint32 offset;
gboolean active;
/* timestamp */
gint64 timestamp; /* nanoseconds since zero */
gint64 maxage; /* FIXME: not used yet */
GstBufferPoolBufferNewFunction buffer_new;
GstBufferPoolBufferCopyFunction buffer_copy;
GstBufferPoolBufferFreeFunction buffer_free;
/* subbuffer support, who's my parent? */
GstBuffer *parent;
gpointer user_data;
};
/* this is a pointer to the buffer pool (if any) */
GstBufferPool *pool;
gpointer pool_private;
/* utility function pointers, can override default */
GstBufferFreeFunc free; /* free the data associated with the buffer */
GstBufferCopyFunc copy; /* copy the data from one buffer to another */
};
/*< private >*/
void _gst_buffer_initialize (void);
/* initialisation */
void _gst_buffer_initialize (void);
/* creating a new buffer from scratch */
GstBuffer* gst_buffer_new (void);
GstBuffer* gst_buffer_new_from_pool (GstBufferPool *pool, guint32 offset, guint32 size);
void _gst_buffer_free (GstBuffer *buf);
GstBuffer* _gst_buffer_copy (GstBuffer *buf);
/* creating a subbuffer */
GstBuffer* gst_buffer_create_sub (GstBuffer *parent, guint32 offset, guint32 size);
void gst_buffer_print_stats (void);
/* refcounting */
void gst_buffer_ref (GstBuffer *buffer);
void gst_buffer_ref_by_count (GstBuffer *buffer, gint count);
void gst_buffer_unref (GstBuffer *buffer);
#define gst_buffer_ref(buf) GST_BUFFER (gst_data_ref (GST_DATA (buf)))
#define gst_buffer_ref_by_count(buf,c) GST_BUFFER (gst_data_ref_by_count (GST_DATA (buf), c))
#define gst_buffer_unref(buf) gst_data_unref (GST_DATA (buf))
/* copy buffer */
#define gst_buffer_copy(buffer) GST_BUFFER (gst_data_copy (GST_DATA (buffer)))
#define gst_buffer_copy_on_write(buffer) GST_BUFFER (gst_data_copy_on_write (GST_DATA (buffer)))
#define gst_buffer_free(buffer) gst_data_free (GST_DATA (buffer))
/* destroying the buffer */
void gst_buffer_destroy (GstBuffer *buffer);
/* allocation */
GstBuffer* gst_buffer_new (void);
GstBuffer* gst_buffer_new_and_alloc (guint size);
/* copy buffer */
GstBuffer* gst_buffer_copy (GstBuffer *buffer);
/* creating a new buffer from a pool */
GstBuffer* gst_buffer_new_from_pool (GstBufferPool *pool, guint64 offset, guint size);
/* creating a subbuffer */
GstBuffer* gst_buffer_create_sub (GstBuffer *parent, guint offset, guint size);
/* merge, span, or append two buffers, intelligently */
GstBuffer* gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2);
gboolean gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2);
GstBuffer* gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len);
GstBuffer* gst_buffer_append (GstBuffer *buffer, GstBuffer *append);
gboolean gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2);
void gst_buffer_print_stats (void);
/* creating a new buffer pools */
GstBufferPool* gst_buffer_pool_new (GstDataFreeFunction free,
GstDataCopyFunction copy,
GstBufferPoolBufferNewFunction buffer_create,
GstBufferPoolBufferCopyFunction buffer_copy,
GstBufferPoolBufferFreeFunction buffer_free,
gpointer user_data);
gboolean gst_buffer_pool_is_active (GstBufferPool *pool);
void gst_buffer_pool_set_active (GstBufferPool *pool, gboolean active);
GstBufferPool* gst_buffer_pool_get_default (guint size, guint numbuffers);
#define gst_buffer_pool_ref(buf) GST_BUFFER_POOL (gst_data_ref (GST_DATA (buf)))
#define gst_buffer_pool_ref_by_count(buf,c) GST_BUFFER_POOL (gst_data_ref_by_count (GST_DATA (buf), c))
#define gst_buffer_pool_unref(buf) gst_data_unref (GST_DATA (buf))
/* bufferpool operations */
#define gst_buffer_pool_copy(pool) GST_BUFFER_POOL (gst_data_copy (GST_DATA (pool)))
#define gst_buffer_pool_copy_on_write(pool) GST_BUFFER_POOL (gst_data_copy_on_write (GST_DATA (pool)))
#define gst_buffer_pool_free(pool) gst_data_free (GST_DATA (pool))
void gst_buffer_pool_set_user_data (GstBufferPool *pool, gpointer user_data);
gpointer gst_buffer_pool_get_user_data (GstBufferPool *pool);
#ifdef __cplusplus
}
#endif /* __cplusplus */
G_END_DECLS
#endif /* __GST_BUFFER_H__ */
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstbufferpool.c: Buffer-pool operations
*
* 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.
*/
#include "gst_private.h"
#include "gstbuffer.h"
static GMutex *_default_pool_lock;
static GHashTable *_default_pools;
static GstBuffer* gst_buffer_pool_default_buffer_new (GstBufferPool *pool, gint64 location, gint size, gpointer user_data);
static void gst_buffer_pool_default_buffer_free (GstBuffer *buffer);
static void gst_buffer_pool_default_destroy_hook (GstBufferPool *pool, gpointer user_data);
typedef struct _GstBufferPoolDefault GstBufferPoolDefault;
struct _GstBufferPoolDefault {
GMemChunk *mem_chunk;
guint size;
};
void
_gst_buffer_pool_initialize (void)
{
_default_pools = g_hash_table_new(NULL,NULL);
_default_pool_lock = g_mutex_new ();
}
/**
* gst_buffer_pool_new:
*
* Create a new buffer pool.
*
* Returns: new buffer pool
*/
GstBufferPool*
gst_buffer_pool_new (void)
{
GstBufferPool *pool;
pool = g_new0 (GstBufferPool, 1);
GST_DEBUG (GST_CAT_BUFFER,"allocating new buffer pool %p", pool);
/* all hooks and user data set to NULL or 0 by g_new0 */
pool->lock = g_mutex_new ();
#ifdef HAVE_ATOMIC_H
atomic_set (&pool->refcount, 1);
#else
pool->refcount = 1;
#endif
return pool;
}
/**
* gst_buffer_pool_ref:
* @pool: the GstBufferPool to reference
*
* Increment the refcount of this buffer pool.
*/
void
gst_buffer_pool_ref (GstBufferPool *pool)
{
g_return_if_fail (pool != NULL);
GST_DEBUG(GST_CAT_BUFFER,"referencing buffer pool %p from %d", pool, GST_BUFFER_POOL_REFCOUNT(pool));
#ifdef HAVE_ATOMIC_H
atomic_inc (&(pool->refcount));
#else
g_return_if_fail (pool->refcount > 0);
GST_BUFFER_POOL_LOCK (pool);
pool->refcount++;
GST_BUFFER_POOL_UNLOCK (pool);
#endif
}
/**
* gst_buffer_pool_ref_by_count:
* @pool: the GstBufferPool to reference
* @count: a number
*
* Increment the refcount of this buffer pool by the given number.
*/
void
gst_buffer_pool_ref_by_count (GstBufferPool *pool, int count)
{
g_return_if_fail (pool != NULL);
g_return_if_fail (count >= 0);
#ifdef HAVE_ATOMIC_H
g_return_if_fail (atomic_read (&(pool->refcount)) > 0);
atomic_add (count, &(pool->refcount));
#else
g_return_if_fail (pool->refcount > 0);
GST_BUFFER_POOL_LOCK (pool);
pool->refcount += count;
GST_BUFFER_POOL_UNLOCK (pool);
#endif
}
/**
* gst_buffer_pool_unref:
* @pool: the GstBufferPool to unref
*
* Decrement the refcount of this buffer pool. If the refcount is
* zero and the pool is a default implementation,
* the buffer pool will be destroyed.
*/
void
gst_buffer_pool_unref (GstBufferPool *pool)
{
gint zero;
g_return_if_fail (pool != NULL);
GST_DEBUG(GST_CAT_BUFFER, "unreferencing buffer pool %p from %d", pool, GST_BUFFER_POOL_REFCOUNT(pool));
#ifdef HAVE_ATOMIC_H
g_return_if_fail (atomic_read (&(pool->refcount)) > 0);
zero = atomic_dec_and_test (&(pool->refcount));
#else
g_return_if_fail (pool->refcount > 0);
GST_BUFFER_POOL_LOCK (pool);
pool->refcount--;
zero = (pool->refcount == 0);
GST_BUFFER_POOL_UNLOCK (pool);
#endif
/* if we ended up with the refcount at zero, destroy the buffer pool*/
if (zero) {
gst_buffer_pool_destroy (pool);
}
}
/**
* gst_buffer_pool_set_buffer_new_function:
* @pool: the pool to set the buffer create function for
* @create: the create function
*
* Sets the function that will be called when a buffer is created
* from this pool.
*/
void
gst_buffer_pool_set_buffer_new_function (GstBufferPool *pool,
GstBufferPoolBufferNewFunction create)
{
g_return_if_fail (pool != NULL);
pool->buffer_new = create;
}
/**
* gst_buffer_pool_set_buffer_free_function:
* @pool: the pool to set the buffer free function for
* @destroy: the free function
*
* Sets the function that will be called when a buffer is freed
* from this pool.
*/
void
gst_buffer_pool_set_buffer_free_function (GstBufferPool *pool,
GstBufferFreeFunc destroy)
{
g_return_if_fail (pool != NULL);
pool->buffer_free = destroy;
}
/**
* gst_buffer_pool_set_buffer_copy_function:
* @pool: the pool to set the buffer copy function for
* @copy: the copy function
*
* Sets the function that will be called when a buffer is copied.
*
* You may use the default GstBuffer implementation (gst_buffer_copy).
*/
void
gst_buffer_pool_set_buffer_copy_function (GstBufferPool *pool,
GstBufferCopyFunc copy)
{
g_return_if_fail (pool != NULL);
pool->buffer_copy = copy;
}
/**
* gst_buffer_pool_set_destroy_hook:
* @pool: the pool to set the destroy hook for