/**
* gst_buffer_new_allocate:
- * @allocator: the #GstAllocator to use
+ * @allocator: (allow-none): the #GstAllocator to use, or NULL to use the
+ * default allocator
* @size: the size in bytes of the new buffer's data.
* @align: the alignment of the buffer memory
*
* gst_buffer_resize:
* @buffer: a #GstBuffer.
* @offset: the offset adjustement
- * @size: the new size
+ * @size: the new size or -1 to just adjust the offset
*
* Set the total size of the buffer
*/
void
-gst_buffer_resize (GstBuffer * buffer, gssize offset, gsize size)
+gst_buffer_resize (GstBuffer * buffer, gssize offset, gssize size)
{
guint len;
guint i;
bufsize = gst_buffer_get_sizes (buffer, &bufoffs, &bufmax);
GST_CAT_LOG (GST_CAT_BUFFER, "trim %p %" G_GSSIZE_FORMAT "-%" G_GSIZE_FORMAT
- " size:%" G_GSIZE_FORMAT " offs:%" G_GSIZE_FORMAT " max:%" G_GSIZE_FORMAT,
- buffer, offset, size, bufsize, bufoffs, bufmax);
+ " size:%" G_GSIZE_FORMAT " offs:%" G_GSSIZE_FORMAT " max:%"
+ G_GSIZE_FORMAT, buffer, offset, size, bufsize, bufoffs, bufmax);
/* we can't go back further than the current offset or past the end of the
* buffer */
* gst_buffer_unmap:
* @buffer: a #GstBuffer.
* @data: the previously mapped data
- * @size: the size of @data
+ * @size: the size of @data, or -1
*
* Release the memory previously mapped with gst_buffer_map(). Pass -1 to size
* if no update is needed.
* than the maxsize of the memory.
*/
gboolean
-gst_buffer_unmap (GstBuffer * buffer, gpointer data, gsize size)
+gst_buffer_unmap (GstBuffer * buffer, gpointer data, gssize size)
{
gboolean result;
guint len;
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
+ g_return_val_if_fail (size >= -1, FALSE);
len = GST_BUFFER_MEM_LEN (buffer);
guint8 val, gsize size);
gsize gst_buffer_get_sizes (GstBuffer *buffer, gsize *offset, gsize *maxsize);
-void gst_buffer_resize (GstBuffer *buffer, gssize offset, gsize size);
+void gst_buffer_resize (GstBuffer *buffer, gssize offset, gssize size);
/**
* gst_buffer_get_size:
/* getting memory */
gpointer gst_buffer_map (GstBuffer *buffer, gsize *size, gsize *maxsize,
GstMapFlags flags);
-gboolean gst_buffer_unmap (GstBuffer *buffer, gpointer data, gsize size);
+gboolean gst_buffer_unmap (GstBuffer *buffer, gpointer data, gssize size);
/* refcounting */
/**
}
static GstMemory *
-_fallback_copy (GstMemory * mem, gssize offset, gsize size)
+_fallback_copy (GstMemory * mem, gssize offset, gssize size)
{
GstMemory *copy;
guint8 *data, *dest;
* gst_memory_unmap:
* @mem: a #GstMemory
* @data: data to unmap
- * @size: new size of @mem
+ * @size: new size of @mem, or -1
*
* Release the memory pointer obtained with gst_memory_map() and set the size of
* the memory to @size. @size can be set to -1 when the size should not be
* Returns: TRUE when the memory was release successfully.
*/
gboolean
-gst_memory_unmap (GstMemory * mem, gpointer data, gsize size)
+gst_memory_unmap (GstMemory * mem, gpointer data, gssize size)
{
g_return_val_if_fail (mem != NULL, FALSE);
* gst_memory_copy:
* @mem: a #GstMemory
* @offset: an offset to copy
- * @size: size to copy
+ * @size: size to copy or -1 to copy all bytes from offset
*
* Return a copy of @size bytes from @mem starting from @offset. This copy is
* guaranteed to be writable. @size can be set to -1 to return a copy all bytes
* Returns: a new #GstMemory.
*/
GstMemory *
-gst_memory_copy (GstMemory * mem, gssize offset, gsize size)
+gst_memory_copy (GstMemory * mem, gssize offset, gssize size)
{
g_return_val_if_fail (mem != NULL, NULL);
* gst_memory_share:
* @mem: a #GstMemory
* @offset: an offset to share
- * @size: size to share
+ * @size: size to share or -1 to share bytes from offset
*
- * Return a shared copy of @size bytes from @mem starting from @offset. No memory
- * copy is performed and the memory region is simply shared. The result is
- * guaranteed to be not-writable. @size can be set to -1 to return a share all bytes
- * from @offset.
+ * Return a shared copy of @size bytes from @mem starting from @offset. No
+ * memory copy is performed and the memory region is simply shared. The result
+ * is guaranteed to be not-writable. @size can be set to -1 to return a share
+ * all bytes from @offset.
*
* Returns: a new #GstMemory.
*/
GstMemory *
-gst_memory_share (GstMemory * mem, gssize offset, gsize size)
+gst_memory_share (GstMemory * mem, gssize offset, gssize size)
{
g_return_val_if_fail (mem != NULL, NULL);
* GstMemoryResizeFunction:
* @mem: a #GstMemory
* @offset: the offset adjustement
- * @size: the new size
+ * @size: the new size or -1 to just adjust the offset
*
* Adjust the size and offset of @mem. @offset bytes will be adjusted from the
* current first byte in @mem as retrieved with gst_memory_map() and the new
*
* @size can be set to -1, which will only adjust the offset.
*/
-typedef void (*GstMemoryResizeFunction) (GstMemory *mem, gssize offset, gsize size);
+typedef void (*GstMemoryResizeFunction) (GstMemory *mem, gssize offset, gssize size);
/**
* GstMemoryMapFunction:
* GstMemoryUnmapFunction:
* @mem: a #GstMemory
* @data: the data pointer
- * @size: the new size
+ * @size: the new size, or -1 to not modify the size
*
* Return the pointer previously retrieved with gst_memory_map() and adjust the
* size of the memory with @size. @size can optionally be set to -1 to not
*
* Returns: %TRUE on success.
*/
-typedef gboolean (*GstMemoryUnmapFunction) (GstMemory *mem, gpointer data, gsize size);
+typedef gboolean (*GstMemoryUnmapFunction) (GstMemory *mem, gpointer data, gssize size);
/**
* GstMemoryFreeFunction:
* GstMemoryCopyFunction:
* @mem: a #GstMemory
* @offset: an offset
- * @size: a size
+ * @size: a size or -1
*
* Copy @size bytes from @mem starting at @offset and return them wrapped in a
* new GstMemory object.
* Returns: a new #GstMemory object wrapping a copy of the requested region in
* @mem.
*/
-typedef GstMemory * (*GstMemoryCopyFunction) (GstMemory *mem, gssize offset, gsize size);
+typedef GstMemory * (*GstMemoryCopyFunction) (GstMemory *mem, gssize offset, gssize size);
/**
* GstMemoryShareFunction:
* @mem: a #GstMemory
* @offset: an offset
- * @size: a size
+ * @size: a size or -1
*
* Share @size bytes from @mem starting at @offset and return them wrapped in a
* new GstMemory object. If @size is set to -1, all bytes starting at @offset are
*
* Returns: a new #GstMemory object sharing the requested region in @mem.
*/
-typedef GstMemory * (*GstMemoryShareFunction) (GstMemory *mem, gssize offset, gsize size);
+typedef GstMemory * (*GstMemoryShareFunction) (GstMemory *mem, gssize offset, gssize size);
/**
* GstMemoryIsSpanFunction:
/* retrieving data */
gpointer gst_memory_map (GstMemory *mem, gsize *size, gsize *maxsize,
GstMapFlags flags);
-gboolean gst_memory_unmap (GstMemory *mem, gpointer data, gsize size);
+gboolean gst_memory_unmap (GstMemory *mem, gpointer data, gssize size);
/* copy and subregions */
-GstMemory * gst_memory_copy (GstMemory *mem, gssize offset, gsize size);
-GstMemory * gst_memory_share (GstMemory *mem, gssize offset, gsize size);
+GstMemory * gst_memory_copy (GstMemory *mem, gssize offset, gssize size);
+GstMemory * gst_memory_share (GstMemory *mem, gssize offset, gssize size);
/* span memory */
gboolean gst_memory_is_span (GstMemory *mem1, GstMemory *mem2, gsize *offset);