mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
memory: add memory type
Add memory type when registering memory allocators. Add getter for the memory type.
This commit is contained in:
parent
dad60ef5c6
commit
16d9a9efbe
2 changed files with 43 additions and 22 deletions
|
@ -320,6 +320,7 @@ void
|
|||
_priv_gst_memory_initialize (void)
|
||||
{
|
||||
static const GstMemoryInfo _mem_info = {
|
||||
GST_ALLOCATOR_SYSMEM,
|
||||
(GstAllocatorAllocFunction) _default_alloc_alloc,
|
||||
(GstMemoryMapFunction) _default_mem_map,
|
||||
(GstMemoryUnmapFunction) _default_mem_unmap,
|
||||
|
@ -779,6 +780,22 @@ gst_allocator_new (const GstMemoryInfo * info, gpointer user_data,
|
|||
return allocator;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_alocator_get_memory_type:
|
||||
* @allocator: a #GstAllocator
|
||||
*
|
||||
* Get the memory type allocated by this allocator
|
||||
*
|
||||
* Returns: @allocator with increased refcount
|
||||
*/
|
||||
const gchar *
|
||||
gst_allocator_get_memory_type (GstAllocator * allocator)
|
||||
{
|
||||
g_return_val_if_fail (allocator != NULL, NULL);
|
||||
|
||||
return allocator->info.mem_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_alocator_ref:
|
||||
* @allocator: a #GstAllocator
|
||||
|
|
|
@ -232,6 +232,7 @@ typedef gboolean (*GstMemoryIsSpanFunction) (GstMemory *mem1, GstMemory *m
|
|||
|
||||
/**
|
||||
* GstMemoryInfo:
|
||||
* @type: the memory type this allocator provides
|
||||
* @alloc: the implementation of the GstAllocatorAllocFunction
|
||||
* @mem_map: the implementation of the GstMemoryMapFunction
|
||||
* @mem_unmap: the implementation of the GstMemoryUnmapFunction
|
||||
|
@ -244,6 +245,8 @@ typedef gboolean (*GstMemoryIsSpanFunction) (GstMemory *mem1, GstMemory *m
|
|||
* the implementations for various memory operations.
|
||||
*/
|
||||
struct _GstMemoryInfo {
|
||||
const gchar *mem_type;
|
||||
|
||||
GstAllocatorAllocFunction alloc;
|
||||
|
||||
GstMemoryMapFunction mem_map;
|
||||
|
@ -261,6 +264,7 @@ struct _GstMemoryInfo {
|
|||
/* allocators */
|
||||
GstAllocator * gst_allocator_new (const GstMemoryInfo * info,
|
||||
gpointer user_data, GDestroyNotify notify);
|
||||
const gchar * gst_allocator_get_memory_type (GstAllocator * allocator);
|
||||
|
||||
GstAllocator * gst_allocator_ref (GstAllocator * allocator);
|
||||
void gst_allocator_unref (GstAllocator * allocator);
|
||||
|
|
Loading…
Reference in a new issue