Commit 3884bade authored by Wim Taymans's avatar Wim Taymans

memory: rename GstMemoryAllocator -> GstAllocator

simplify the name of the allocator object.
parent c6a38783
......@@ -464,7 +464,7 @@ gst_buffer_new (void)
/**
* 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
*
......@@ -484,7 +484,7 @@ gst_buffer_new (void)
* 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;
......@@ -496,7 +496,7 @@ gst_buffer_new_allocate (const GstMemoryAllocator * allocator, gsize size,
#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 {
......@@ -534,7 +534,7 @@ gst_buffer_new_allocate (const GstMemoryAllocator * allocator, gsize size,
* 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;
......@@ -1152,7 +1152,7 @@ _gst_buffer_arr_span (GstMemory ** mem[], gsize len[], guint n, gsize offset,
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;
......
......@@ -226,7 +226,7 @@ struct _GstBuffer {
/* 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);
......
......@@ -164,8 +164,7 @@ default_alloc_buffer (GstBufferPool * pool, 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);
......
......@@ -27,13 +27,13 @@
* 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.
......@@ -79,7 +79,7 @@ size_t gst_memory_alignment = 0;
#endif
#endif /* HAVE_POSIX_MEMALIGN */
struct _GstMemoryAllocator
struct _GstAllocator
{
GQuark name;
......@@ -99,10 +99,10 @@ typedef struct
} 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
......@@ -170,8 +170,7 @@ _default_mem_new_block (gsize maxsize, gsize align, gsize offset, gsize size)
}
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);
}
......@@ -287,7 +286,7 @@ _fallback_copy (GstMemory * mem, gsize offset, gsize size)
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);
......@@ -330,8 +329,7 @@ _gst_memory_init (void)
#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;
}
......@@ -556,7 +554,7 @@ gst_memory_is_span (GstMemory * mem1, GstMemory * mem2, gsize * offset)
}
/**
* gst_memory_allocator_register:
* gst_allocator_register:
* @name: the name of the allocator
* @info: #GstMemoryInfo
*
......@@ -569,12 +567,12 @@ gst_memory_is_span (GstMemory * mem1, GstMemory * mem2, gsize * offset)
* 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;
......@@ -589,7 +587,7 @@ gst_memory_allocator_register (const gchar * name, const GstMemoryInfo * info)
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);
......@@ -606,19 +604,19 @@ gst_memory_allocator_register (const gchar * name, const GstMemoryInfo * info)
}
/**
* 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) {
......@@ -632,13 +630,13 @@ gst_memory_allocator_find (const gchar * 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);
......@@ -648,8 +646,8 @@ gst_memory_allocator_set_default (const GstMemoryAllocator * allocator)
}
/**
* 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
*
......@@ -664,8 +662,7 @@ gst_memory_allocator_set_default (const GstMemoryAllocator * allocator)
* 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);
......
......@@ -31,7 +31,7 @@ G_BEGIN_DECLS
typedef struct _GstMemory GstMemory;
typedef struct _GstMemoryInfo GstMemoryInfo;
typedef struct _GstMemoryAllocator GstMemoryAllocator;
typedef struct _GstAllocator GstAllocator;
extern gsize gst_memory_alignment;
......@@ -64,7 +64,7 @@ typedef enum {
/**
* GstMemory:
* @allocator: pointer to the #GstMemoryAllocator
* @allocator: pointer to the #GstAllocator
* @flags: memory flags
* @refcount: refcount
* @parent: parent memory block
......@@ -73,7 +73,7 @@ typedef enum {
* as the first member of their structure.
*/
struct _GstMemory {
const GstMemoryAllocator *allocator;
const GstAllocator *allocator;
GstMemoryFlags flags;
gint refcount;
......@@ -100,15 +100,15 @@ typedef enum {
#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
......@@ -120,7 +120,7 @@ typedef enum {
*
* 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);
......@@ -266,14 +266,15 @@ struct _GstMemoryInfo {
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);
......
......@@ -240,7 +240,7 @@ struct _GstBaseSrcPrivate
GstClockTime earliest_time;
GstBufferPool *pool;
const GstMemoryAllocator *allocator;
const GstAllocator *allocator;
guint prefix;
guint alignment;
};
......@@ -2602,7 +2602,7 @@ null_buffer:
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;
......@@ -2662,7 +2662,7 @@ gst_base_src_prepare_allocation (GstBaseSrc * basesrc, GstCaps * caps)
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);
......@@ -2692,7 +2692,7 @@ gst_base_src_prepare_allocation (GstBaseSrc * basesrc, GstCaps * caps)
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;
......
......@@ -253,7 +253,7 @@ struct _GstBaseTransformPrivate
GstClockTime position_out;
GstBufferPool *pool;
const GstMemoryAllocator *allocator;
const GstAllocator *allocator;
guint prefix;
guint alignment;
};
......@@ -712,7 +712,7 @@ done:
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;
......@@ -754,7 +754,7 @@ gst_base_transform_do_bufferpool (GstBaseTransform * trans, GstCaps * outcaps)
GstBufferPool *pool = NULL, *oldpool;
guint size, min, max, prefix, alignment;
GstBaseTransformClass *klass;
const GstMemoryAllocator *allocator = NULL;
const GstAllocator *allocator = NULL;
/* there are these possibilities:
*
......@@ -804,7 +804,7 @@ gst_base_transform_do_bufferpool (GstBaseTransform * trans, GstCaps * outcaps)
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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment