#include "gstbuffer.h"
#include "gstmemchunk.h"
#include "gstlog.h"
+#include "gstbufferpool-default.h"
GType _gst_buffer_type;
GType _gst_buffer_pool_type;
{
GstBufferPool *pool = buffer->pool;
- buffer->pool->buffer_free (buffer->pool, buffer, buffer->pool->user_data);
+ pool->buffer_free (pool, buffer, pool->user_data);
gst_data_unref (GST_DATA (pool));
}
* gst_buffer_default_free:
* @buffer: a #GstBuffer to free
*
- * Free the momory associated with the buffer including the buffer data,
+ * Free the memory associated with the buffer including the buffer data,
* unless the GST_BUFFER_DONTFREE flags was set or the buffer data is NULL.
* This function is used by bufferpools.
*/
_gst_buffer_live--;
}
+static GstBuffer*
+_gst_buffer_copy_from_pool (GstBuffer *buffer)
+{
+ return buffer->pool->buffer_copy (buffer->pool, buffer, buffer->pool->user_data);
+}
+
/**
* gst_buffer_default_copy:
* @buffer: a #GstBuffer to make a copy of
return copy;
}
-static GstBuffer*
-_gst_buffer_copy_to_pool (GstBuffer *buffer)
-{
- return buffer->pool->buffer_copy (buffer->pool, buffer, buffer->pool->user_data);
-}
-
-
/**
* gst_buffer_new:
*
{
GstBuffer *buffer;
+ g_return_val_if_fail (pool != NULL, NULL);
+
buffer = pool->buffer_new (pool, offset, size, pool->user_data);
if (!buffer)
return NULL;
/* override the buffer refcount functions with those from the pool (if any) */
if (pool->buffer_free)
- GST_DATA (buffer)->free = (GstDataFreeFunction) _gst_buffer_free_to_pool;
+ GST_DATA (buffer)->free = (GstDataFreeFunction)_gst_buffer_free_to_pool;
if (pool->buffer_copy)
- GST_DATA (buffer)->copy = (GstDataCopyFunction) _gst_buffer_copy_to_pool;
+ GST_DATA (buffer)->copy = (GstDataCopyFunction)_gst_buffer_copy_from_pool;
return buffer;
}
return newbuf;
}
-static void
-_gst_buffer_pool_free (GstBufferPool *pool)
+void
+gst_buffer_pool_default_free (GstBufferPool *pool)
{
_GST_DATA_DISPOSE (GST_DATA (pool));
g_free (pool);
pool = g_new0 (GstBufferPool, 1);
_gst_buffer_pool_live++;
- GST_DEBUG (GST_CAT_BUFFER,"allocating new buffer pool %p\n", pool);
+
+ GST_DEBUG (GST_CAT_BUFFER, "allocating new buffer pool %p\n", pool);
/* init data struct */
_GST_DATA_INIT (GST_DATA (pool),
_gst_buffer_pool_type,
0,
- (free ? free : (GstDataFreeFunction) _gst_buffer_pool_free),
+ (free ? free : (GstDataFreeFunction) gst_buffer_pool_default_free),
copy);
/* set functions */
*
* Returns: A new bufferpool to create buffers of the given size.
*/
-/* FIXME */
GstBufferPool*
gst_buffer_pool_get_default (guint size, guint numbuffers)
{
- return NULL;
+ return _gst_buffer_pool_get_default (size, numbuffers);
}