mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 13:38:48 +00:00
memory: provide a mem_map_full that takes the GstMapInfo
Follow up of 7130230ddb
Provide the memory implementation the GstMapInfo that will be used to
map/unmap the memory. This allows the memory implementation to use
some scratch space in GstMapInfo to e.g. track different map/unmap
behaviour or store extra implementation defined data about the map
in use.
https://bugzilla.gnome.org/show_bug.cgi?id=750319
This commit is contained in:
parent
faf05a4194
commit
d61ba38118
4 changed files with 34 additions and 10 deletions
|
@ -1456,7 +1456,9 @@ GstMapInfo
|
||||||
GST_MAP_INFO_INIT
|
GST_MAP_INFO_INIT
|
||||||
|
|
||||||
GstMemoryMapFunction
|
GstMemoryMapFunction
|
||||||
|
GstMemoryMapFullFunction
|
||||||
GstMemoryUnmapFunction
|
GstMemoryUnmapFunction
|
||||||
|
GstMemoryUnmapFullFunction
|
||||||
GstMemoryCopyFunction
|
GstMemoryCopyFunction
|
||||||
GstMemoryShareFunction
|
GstMemoryShareFunction
|
||||||
GstMemoryIsSpanFunction
|
GstMemoryIsSpanFunction
|
||||||
|
|
|
@ -97,6 +97,8 @@ typedef enum {
|
||||||
* @mem_copy: the implementation of the GstMemoryCopyFunction
|
* @mem_copy: the implementation of the GstMemoryCopyFunction
|
||||||
* @mem_share: the implementation of the GstMemoryShareFunction
|
* @mem_share: the implementation of the GstMemoryShareFunction
|
||||||
* @mem_is_span: the implementation of the GstMemoryIsSpanFunction
|
* @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.
|
* @mem_unmap_full: the implementation of the GstMemoryUnmapFullFunction.
|
||||||
* Will be used instead of @mem_unmap if present. Since 1.6
|
* Will be used instead of @mem_unmap if present. Since 1.6
|
||||||
*
|
*
|
||||||
|
@ -116,10 +118,11 @@ struct _GstAllocator
|
||||||
GstMemoryShareFunction mem_share;
|
GstMemoryShareFunction mem_share;
|
||||||
GstMemoryIsSpanFunction mem_is_span;
|
GstMemoryIsSpanFunction mem_is_span;
|
||||||
|
|
||||||
|
GstMemoryMapFullFunction mem_map_full;
|
||||||
GstMemoryUnmapFullFunction mem_unmap_full;
|
GstMemoryUnmapFullFunction mem_unmap_full;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
gpointer _gst_reserved[GST_PADDING - 1];
|
gpointer _gst_reserved[GST_PADDING - 2];
|
||||||
|
|
||||||
GstAllocatorPrivate *priv;
|
GstAllocatorPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
|
@ -294,15 +294,19 @@ gst_memory_map (GstMemory * mem, GstMapInfo * info, GstMapFlags flags)
|
||||||
if (!gst_memory_lock (mem, (GstLockFlags) flags))
|
if (!gst_memory_lock (mem, (GstLockFlags) flags))
|
||||||
goto lock_failed;
|
goto lock_failed;
|
||||||
|
|
||||||
info->data = mem->allocator->mem_map (mem, mem->maxsize, flags);
|
info->flags = flags;
|
||||||
|
info->memory = mem;
|
||||||
|
info->size = mem->size;
|
||||||
|
info->maxsize = mem->maxsize - mem->offset;
|
||||||
|
|
||||||
|
if (mem->allocator->mem_map_full)
|
||||||
|
info->data = mem->allocator->mem_map_full (mem, info, mem->maxsize);
|
||||||
|
else
|
||||||
|
info->data = mem->allocator->mem_map (mem, mem->maxsize, flags);
|
||||||
|
|
||||||
if (G_UNLIKELY (info->data == NULL))
|
if (G_UNLIKELY (info->data == NULL))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
info->memory = mem;
|
|
||||||
info->flags = flags;
|
|
||||||
info->size = mem->size;
|
|
||||||
info->maxsize = mem->maxsize - mem->offset;
|
|
||||||
info->data = info->data + mem->offset;
|
info->data = info->data + mem->offset;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -339,7 +343,7 @@ gst_memory_unmap (GstMemory * mem, GstMapInfo * info)
|
||||||
g_return_if_fail (info->memory == mem);
|
g_return_if_fail (info->memory == mem);
|
||||||
|
|
||||||
if (mem->allocator->mem_unmap_full)
|
if (mem->allocator->mem_unmap_full)
|
||||||
mem->allocator->mem_unmap_full (mem, info->flags);
|
mem->allocator->mem_unmap_full (mem, info);
|
||||||
else
|
else
|
||||||
mem->allocator->mem_unmap (mem);
|
mem->allocator->mem_unmap (mem);
|
||||||
gst_memory_unlock (mem, (GstLockFlags) info->flags);
|
gst_memory_unlock (mem, (GstLockFlags) info->flags);
|
||||||
|
|
|
@ -232,6 +232,21 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize maxsize, GstMapFlags flags);
|
typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize maxsize, GstMapFlags flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstMemoryMapFullFunction:
|
||||||
|
* @mem: a #GstMemory
|
||||||
|
* @info: the #GstMapInfo to map with
|
||||||
|
* @maxsize: size to map
|
||||||
|
*
|
||||||
|
* Get the memory of @mem that can be accessed according to the mode specified
|
||||||
|
* in @info's flags. The function should return a pointer that contains at least
|
||||||
|
* @maxsize bytes.
|
||||||
|
*
|
||||||
|
* Returns: a pointer to memory of which at least @maxsize bytes can be
|
||||||
|
* accessed according to the access pattern in @info's flags.
|
||||||
|
*/
|
||||||
|
typedef gpointer (*GstMemoryMapFullFunction) (GstMemory *mem, GstMapInfo * info, gsize maxsize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstMemoryUnmapFunction:
|
* GstMemoryUnmapFunction:
|
||||||
* @mem: a #GstMemory
|
* @mem: a #GstMemory
|
||||||
|
@ -243,11 +258,11 @@ typedef void (*GstMemoryUnmapFunction) (GstMemory *mem);
|
||||||
/**
|
/**
|
||||||
* GstMemoryUnmapFullFunction:
|
* GstMemoryUnmapFullFunction:
|
||||||
* @mem: a #GstMemory
|
* @mem: a #GstMemory
|
||||||
* @flags: a #GstMapFlags
|
* @info: a #GstMapInfo
|
||||||
*
|
*
|
||||||
* Return the pointer previously retrieved with gst_memory_map() with @flags.
|
* Return the pointer previously retrieved with gst_memory_map() with @info.
|
||||||
*/
|
*/
|
||||||
typedef void (*GstMemoryUnmapFullFunction) (GstMemory *mem, GstMapFlags flags);
|
typedef void (*GstMemoryUnmapFullFunction) (GstMemory *mem, GstMapInfo * info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstMemoryCopyFunction:
|
* GstMemoryCopyFunction:
|
||||||
|
|
Loading…
Reference in a new issue