diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index ce6249b9b8..f818526743 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1456,7 +1456,9 @@ GstMapInfo GST_MAP_INFO_INIT GstMemoryMapFunction +GstMemoryMapFullFunction GstMemoryUnmapFunction +GstMemoryUnmapFullFunction GstMemoryCopyFunction GstMemoryShareFunction GstMemoryIsSpanFunction diff --git a/gst/gstallocator.h b/gst/gstallocator.h index 5dadd441eb..4ca2cb91bf 100644 --- a/gst/gstallocator.h +++ b/gst/gstallocator.h @@ -97,6 +97,8 @@ typedef enum { * @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 * @@ -116,10 +118,11 @@ struct _GstAllocator GstMemoryShareFunction mem_share; GstMemoryIsSpanFunction mem_is_span; + GstMemoryMapFullFunction mem_map_full; GstMemoryUnmapFullFunction mem_unmap_full; /*< private >*/ - gpointer _gst_reserved[GST_PADDING - 1]; + gpointer _gst_reserved[GST_PADDING - 2]; GstAllocatorPrivate *priv; }; diff --git a/gst/gstmemory.c b/gst/gstmemory.c index 511a6f3dd5..09c429f89f 100644 --- a/gst/gstmemory.c +++ b/gst/gstmemory.c @@ -294,15 +294,19 @@ gst_memory_map (GstMemory * mem, GstMapInfo * info, GstMapFlags flags) if (!gst_memory_lock (mem, (GstLockFlags) flags)) 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)) goto error; - info->memory = mem; - info->flags = flags; - info->size = mem->size; - info->maxsize = mem->maxsize - mem->offset; info->data = info->data + mem->offset; return TRUE; @@ -339,7 +343,7 @@ gst_memory_unmap (GstMemory * mem, GstMapInfo * info) g_return_if_fail (info->memory == mem); if (mem->allocator->mem_unmap_full) - mem->allocator->mem_unmap_full (mem, info->flags); + mem->allocator->mem_unmap_full (mem, info); else mem->allocator->mem_unmap (mem); gst_memory_unlock (mem, (GstLockFlags) info->flags); diff --git a/gst/gstmemory.h b/gst/gstmemory.h index 5c66464b01..6ec79022e1 100644 --- a/gst/gstmemory.h +++ b/gst/gstmemory.h @@ -232,6 +232,21 @@ typedef struct { */ 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: * @mem: a #GstMemory @@ -243,11 +258,11 @@ typedef void (*GstMemoryUnmapFunction) (GstMemory *mem); /** * GstMemoryUnmapFullFunction: * @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: