*
* 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.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#define __GST_ALLOCATOR_H__
#include <gst/gstmemory.h>
+#include <gst/gstobject.h>
G_BEGIN_DECLS
#define GST_ALLOCATOR_CAST(obj) ((GstAllocator *)(obj))
#define GST_TYPE_ALLOCATION_PARAMS (gst_allocation_params_get_type())
+
+GST_API
GType gst_allocation_params_get_type(void);
typedef struct _GstAllocationParams GstAllocationParams;
* The default memory alignment in bytes - 1
* an alignment of 7 would be the same as what malloc() guarantees.
*/
-GST_EXPORT gsize gst_memory_alignment;
+
+GST_API gsize gst_memory_alignment;
/**
* GST_ALLOCATOR_SYSMEM:
gpointer _gst_reserved[GST_PADDING];
};
-#if 0
-/**
- * GstAllocatorAllocFunction:
- * @allocator: a #GstAllocator
- * @size: the size
- * @params: allocator params
- * @user_data: user data
- *
- * Allocate a new #GstMemory from @allocator that can hold at least @size
- * bytes (+ padding) and is aligned to (@align + 1) bytes.
- *
- * The offset and size of the memory should be set and the prefix/padding must
- * be filled with 0 if @params flags contains #GST_MEMORY_FLAG_ZERO_PREFIXED and
- * #GST_MEMORY_FLAG_ZERO_PADDED respectively.
- *
- * @user_data is extra data passed to this function. The default
- * gst_allocator_alloc() passes the NULL but other implementations could pass
- * custom data.
- *
- * Returns: a newly allocated #GstMemory. Free with gst_memory_unref()
- */
-typedef GstMemory * (*GstAllocatorAllocFunction) (GstAllocator *allocator,
- gsize size, GstAllocationParams *params,
- gpointer user_data);
-#endif
-
/**
* GstAllocatorFlags:
- * @GST_ALLOCATOR_CUSTOM_ALLOC: The allocator has a custom alloc function.
+ * @GST_ALLOCATOR_FLAG_CUSTOM_ALLOC: The allocator has a custom alloc function.
* @GST_ALLOCATOR_FLAG_LAST: first flag that can be used for custom purposes
*
* Flags for allocators.
/**
* GstAllocator:
- * @mini_object: parent structure
- * @mem_type: the memory type this allocator provides
* @mem_map: the implementation of the GstMemoryMapFunction
* @mem_unmap: the implementation of the GstMemoryUnmapFunction
- * @mem_free: the implementation of the GstMemoryFreeFunction
* @mem_copy: the implementation of the GstMemoryCopyFunction
* @mem_share: the implementation of the GstMemoryShareFunction
* @mem_is_span: the implementation of the GstMemoryIsSpanFunction
+ * @mem_map_full: the implementation of the GstMemoryMapFullFunction.
+ * Will be used instead of @mem_map if present. (Since: 1.6)
+ * @mem_unmap_full: the implementation of the GstMemoryUnmapFullFunction.
+ * Will be used instead of @mem_unmap if present. (Since: 1.6)
*
* The #GstAllocator is used to create new memory.
*/
{
GstObject object;
- const gchar *mem_type;
+ const gchar *mem_type;
- GstMemoryMapFunction mem_map;
- GstMemoryUnmapFunction mem_unmap;
+ /*< public >*/
+ GstMemoryMapFunction mem_map;
+ GstMemoryUnmapFunction mem_unmap;
- GstMemoryCopyFunction mem_copy;
- GstMemoryShareFunction mem_share;
- GstMemoryIsSpanFunction mem_is_span;
+ GstMemoryCopyFunction mem_copy;
+ GstMemoryShareFunction mem_share;
+ GstMemoryIsSpanFunction mem_is_span;
- gpointer _gst_reserved[GST_PADDING];
+ GstMemoryMapFullFunction mem_map_full;
+ GstMemoryUnmapFullFunction mem_unmap_full;
/*< private >*/
+ gpointer _gst_reserved[GST_PADDING - 2];
+
GstAllocatorPrivate *priv;
};
+/**
+ * GstAllocatorClass:
+ * @object_class: Object parent class
+ * @alloc: implementation that acquires memory
+ * @free: implementation that releases memory
+ *
+ * The #GstAllocator is used to create new memory.
+ */
struct _GstAllocatorClass {
GstObjectClass object_class;
+ /*< public >*/
GstMemory * (*alloc) (GstAllocator *allocator, gsize size,
- GstAllocationParams *params, gpointer user_data);
+ GstAllocationParams *params);
void (*free) (GstAllocator *allocator, GstMemory *memory);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_allocator_get_type(void);
+GST_API
+GType gst_allocator_get_type (void);
/* allocators */
+
+GST_API
void gst_allocator_register (const gchar *name, GstAllocator *allocator);
+
+GST_API
GstAllocator * gst_allocator_find (const gchar *name);
+
+GST_API
void gst_allocator_set_default (GstAllocator * allocator);
/* allocation parameters */
+
+GST_API
void gst_allocation_params_init (GstAllocationParams *params);
+
+GST_API
GstAllocationParams *
gst_allocation_params_copy (const GstAllocationParams *params) G_GNUC_MALLOC;
+
+GST_API
void gst_allocation_params_free (GstAllocationParams *params);
/* allocating memory blocks */
+
+GST_API
GstMemory * gst_allocator_alloc (GstAllocator * allocator, gsize size,
GstAllocationParams *params);
-void gst_allocator_free (GstAllocator * allocator, GstMemory *mem);
+GST_API
+void gst_allocator_free (GstAllocator * allocator, GstMemory *memory);
+
+GST_API
GstMemory * gst_memory_new_wrapped (GstMemoryFlags flags, gpointer data, gsize maxsize,
gsize offset, gsize size, gpointer user_data,
GDestroyNotify notify);
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAllocationParams, gst_allocation_params_free)
+#endif
+
G_END_DECLS
#endif /* __GST_ALLOCATOR_H__ */