simplify the name of the allocator object.
/**
* gst_buffer_new_allocate:
- * @allocator: the #GstMemoryAllocator to use
+ * @allocator: the #GstAllocator to use
* @size: the size in bytes of the new buffer's data.
* @align: the alignment of the buffer memory
*
* be allocated.
*/
GstBuffer *
-gst_buffer_new_allocate (const GstMemoryAllocator * allocator, gsize size,
+gst_buffer_new_allocate (const GstAllocator * allocator, gsize size,
gsize align)
{
GstBuffer *newbuf;
#if 1
if (size > 0) {
- mem = gst_memory_allocator_alloc (allocator, size, align);
+ mem = gst_allocator_alloc (allocator, size, align);
if (G_UNLIKELY (mem == NULL))
goto no_memory;
} else {
* buffer fields and the memory for the buffer might be just very slow. We
* also need to do some more magic to get the alignment right. */
asize = sizeof (GstBufferImpl) + size;
- mem = gst_memory_allocator_alloc (allocator, asize, align);
+ mem = gst_allocator_alloc (allocator, asize, align);
if (G_UNLIKELY (mem == NULL))
goto no_memory;
gsize count, left;
guint8 *dest, *ptr;
- span = gst_memory_allocator_alloc (NULL, size, 0);
+ span = gst_allocator_alloc (NULL, size, 0);
dest = gst_memory_map (span, NULL, NULL, GST_MAP_WRITE);
ptr = dest;
/* allocation */
GstBuffer * gst_buffer_new (void);
-GstBuffer * gst_buffer_new_allocate (const GstMemoryAllocator * allocator, gsize maxsize, gsize align);
+GstBuffer * gst_buffer_new_allocate (const GstAllocator * allocator, gsize maxsize, gsize align);
/* memory blocks */
guint gst_buffer_n_memory (GstBuffer *buffer);
*buffer = gst_buffer_new ();
- mem =
- gst_memory_allocator_alloc (NULL, priv->size + priv->prefix, priv->align);
+ mem = gst_allocator_alloc (NULL, priv->size + priv->prefix, priv->align);
gst_memory_resize (mem, priv->prefix, priv->size);
gst_buffer_take_memory (*buffer, -1, mem);
* GstMemory is a lightweight refcounted object that wraps a region of memory.
* They are typically used to manage the data of a #GstBuffer.
*
- * Memory is usually created by allocators with a gst_memory_allocator_alloc()
+ * Memory is usually created by allocators with a gst_allocator_alloc()
* method call. When NULL is used as the allocator, the default allocator will
* be used.
*
- * New allocators can be registered with gst_memory_allocator_register().
+ * New allocators can be registered with gst_allocator_register().
* Allocators are identified by name and can be retrieved with
- * gst_memory_allocator_find().
+ * gst_allocator_find().
*
* New memory can be created with gst_memory_new_wrapped() that wraps the memory
* allocated elsewhere.
#endif
#endif /* HAVE_POSIX_MEMALIGN */
-struct _GstMemoryAllocator
+struct _GstAllocator
{
GQuark name;
} GstMemoryDefault;
/* the default allocator */
-static const GstMemoryAllocator *_default_allocator;
+static const GstAllocator *_default_allocator;
/* our predefined allocators */
-static const GstMemoryAllocator *_default_mem_impl;
+static const GstAllocator *_default_mem_impl;
/* initialize the fields */
static void
}
static GstMemory *
-_default_mem_alloc (const GstMemoryAllocator * allocator, gsize maxsize,
- gsize align)
+_default_mem_alloc (const GstAllocator * allocator, gsize maxsize, gsize align)
{
return (GstMemory *) _default_mem_new_block (maxsize, align, 0, maxsize);
}
if (size == -1)
size = msize > offset ? msize - offset : 0;
/* use the same allocator as the memory we copy, FIXME, alignment? */
- copy = gst_memory_allocator_alloc (mem->allocator, size, 1);
+ copy = gst_allocator_alloc (mem->allocator, size, 1);
dest = gst_memory_map (copy, NULL, NULL, GST_MAP_WRITE);
memcpy (dest, data + offset, size);
gst_memory_unmap (copy, dest, size);
#endif
#endif
- _default_mem_impl =
- gst_memory_allocator_register ("GstMemoryDefault", &_mem_info);
+ _default_mem_impl = gst_allocator_register (GST_ALLOCATOR_SYSMEM, &_mem_info);
_default_allocator = _default_mem_impl;
}
}
/**
- * gst_memory_allocator_register:
+ * gst_allocator_register:
* @name: the name of the allocator
* @info: #GstMemoryInfo
*
* The user_data field in @info will be passed to all calls of the alloc
* function.
*
- * Returns: a new #GstMemoryAllocator.
+ * Returns: a new #GstAllocator.
*/
-const GstMemoryAllocator *
-gst_memory_allocator_register (const gchar * name, const GstMemoryInfo * info)
+const GstAllocator *
+gst_allocator_register (const gchar * name, const GstMemoryInfo * info)
{
- GstMemoryAllocator *allocator;
+ GstAllocator *allocator;
#define INSTALL_FALLBACK(_t) \
if (allocator->info._t == NULL) allocator->info._t = _fallback_ ##_t;
g_return_val_if_fail (info->free != NULL, NULL);
g_return_val_if_fail (info->share != NULL, NULL);
- allocator = g_slice_new (GstMemoryAllocator);
+ allocator = g_slice_new (GstAllocator);
allocator->name = g_quark_from_string (name);
allocator->info = *info;
INSTALL_FALLBACK (copy);
}
/**
- * gst_memory_allocator_find:
+ * gst_allocator_find:
* @name: the name of the allocator
*
* Find a previously registered allocator with @name. When @name is NULL, the
* default allocator will be returned.
*
- * Returns: a #GstMemoryAllocator or NULL when the allocator with @name was not
+ * Returns: a #GstAllocator or NULL when the allocator with @name was not
* registered.
*/
-const GstMemoryAllocator *
-gst_memory_allocator_find (const gchar * name)
+const GstAllocator *
+gst_allocator_find (const gchar * name)
{
- const GstMemoryAllocator *allocator;
+ const GstAllocator *allocator;
g_static_rw_lock_reader_lock (&lock);
if (name) {
}
/**
- * gst_memory_allocator_set_default:
- * @allocator: a ##GstMemoryAllocator
+ * gst_allocator_set_default:
+ * @allocator: a #GstAllocator
*
* Set the default allocator.
*/
void
-gst_memory_allocator_set_default (const GstMemoryAllocator * allocator)
+gst_allocator_set_default (const GstAllocator * allocator)
{
g_return_if_fail (allocator != NULL);
}
/**
- * gst_memory_allocator_alloc:
- * @allocator: a #GstMemoryAllocator to use
+ * gst_allocator_alloc:
+ * @allocator: a #GstAllocator to use
* @maxsize: allocated size of @data
* @align: alignment for the data
*
* Returns: a new #GstMemory.
*/
GstMemory *
-gst_memory_allocator_alloc (const GstMemoryAllocator * allocator,
- gsize maxsize, gsize align)
+gst_allocator_alloc (const GstAllocator * allocator, gsize maxsize, gsize align)
{
g_return_val_if_fail (((align + 1) & align) == 0, NULL);
typedef struct _GstMemory GstMemory;
typedef struct _GstMemoryInfo GstMemoryInfo;
-typedef struct _GstMemoryAllocator GstMemoryAllocator;
+typedef struct _GstAllocator GstAllocator;
extern gsize gst_memory_alignment;
/**
* GstMemory:
- * @allocator: pointer to the #GstMemoryAllocator
+ * @allocator: pointer to the #GstAllocator
* @flags: memory flags
* @refcount: refcount
* @parent: parent memory block
* as the first member of their structure.
*/
struct _GstMemory {
- const GstMemoryAllocator *allocator;
+ const GstAllocator *allocator;
GstMemoryFlags flags;
gint refcount;
#define GST_MAP_READWRITE (GST_MAP_READ | GST_MAP_WRITE)
/**
- * GST_MEMORY_TRACE_NAME:
+ * GST_ALLOCATOR_SYSMEM:
*
- * The name used for tracing memory allocations.
+ * The allocator name for the default system memory allocator
*/
-#define GST_MEMORY_TRACE_NAME "GstMemory"
+#define GST_ALLOCATOR_SYSMEM "SystemMemory"
/**
* GstMemoryAllocFunction:
- * @allocator: a #GstMemoryAllocator
+ * @allocator: a #GstAllocator
* @maxsize: the maxsize
* @align: the alignment
* @user_data: user data
*
* Returns: a newly allocated #GstMemory. Free with gst_memory_unref()
*/
-typedef GstMemory * (*GstMemoryAllocFunction) (const GstMemoryAllocator *allocator,
+typedef GstMemory * (*GstMemoryAllocFunction) (const GstAllocator *allocator,
gsize maxsize, gsize align,
gpointer user_data);
void _gst_memory_init (void);
/* allocators */
-const GstMemoryAllocator * gst_memory_allocator_register (const gchar *name, const GstMemoryInfo *info);
-const GstMemoryAllocator * gst_memory_allocator_find (const gchar *name);
+const GstAllocator * gst_allocator_register (const gchar *name, const GstMemoryInfo *info);
+const GstAllocator * gst_allocator_find (const gchar *name);
-void gst_memory_allocator_set_default (const GstMemoryAllocator * allocator);
+void gst_allocator_set_default (const GstAllocator * allocator);
/* allocating memory blocks */
-GstMemory * gst_memory_allocator_alloc (const GstMemoryAllocator * allocator,
+GstMemory * gst_allocator_alloc (const GstAllocator * allocator,
gsize maxsize, gsize align);
+
GstMemory * gst_memory_new_wrapped (GstMemoryFlags flags, gpointer data, GFreeFunc free_func,
gsize maxsize, gsize offset, gsize size);
GstClockTime earliest_time;
GstBufferPool *pool;
- const GstMemoryAllocator *allocator;
+ const GstAllocator *allocator;
guint prefix;
guint alignment;
};
static gboolean
gst_base_src_set_allocation (GstBaseSrc * basesrc, GstBufferPool * pool,
- const GstMemoryAllocator * allocator, guint prefix, guint alignment)
+ const GstAllocator * allocator, guint prefix, guint alignment)
{
GstBufferPool *oldpool;
GstBaseSrcPrivate *priv = basesrc->priv;
gboolean result = TRUE;
GstQuery *query;
GstBufferPool *pool = NULL;
- const GstMemoryAllocator *allocator = NULL;
+ const GstAllocator *allocator = NULL;
guint size, min, max, prefix, alignment;
bclass = GST_BASE_SRC_GET_CLASS (basesrc);
if (gst_query_get_n_allocation_memories (query) > 0) {
mem = gst_query_parse_nth_allocation_memory (query, 0);
}
- allocator = gst_memory_allocator_find (mem);
+ allocator = gst_allocator_find (mem);
} else if (pool == NULL) {
/* fixed size, we can use a bufferpool */
GstStructure *config;
GstClockTime position_out;
GstBufferPool *pool;
- const GstMemoryAllocator *allocator;
+ const GstAllocator *allocator;
guint prefix;
guint alignment;
};
static gboolean
gst_base_transform_set_allocation (GstBaseTransform * trans,
- GstBufferPool * pool, const GstMemoryAllocator * allocator, guint prefix,
+ GstBufferPool * pool, const GstAllocator * allocator, guint prefix,
guint alignment)
{
GstBufferPool *oldpool;
GstBufferPool *pool = NULL, *oldpool;
guint size, min, max, prefix, alignment;
GstBaseTransformClass *klass;
- const GstMemoryAllocator *allocator = NULL;
+ const GstAllocator *allocator = NULL;
/* there are these possibilities:
*
if (gst_query_get_n_allocation_memories (query) > 0) {
mem = gst_query_parse_nth_allocation_memory (query, 0);
}
- allocator = gst_memory_allocator_find (mem);
+ allocator = gst_allocator_find (mem);
} else if (pool == NULL) {
GstStructure *config;