diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 9b5c380837..3a63a6495f 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -456,7 +456,8 @@ gst_buffer_new (void) /** * 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 * @@ -807,12 +808,12 @@ gst_buffer_get_sizes (GstBuffer * buffer, gsize * offset, gsize * maxsize) * 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; @@ -824,8 +825,8 @@ gst_buffer_resize (GstBuffer * buffer, gssize offset, gsize size) 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 */ @@ -987,7 +988,7 @@ not_writable: * 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. @@ -996,12 +997,13 @@ not_writable: * 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); diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index f3b727788b..46a60f545f 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -295,7 +295,7 @@ gsize gst_buffer_memset (GstBuffer *buffer, gsize offset, 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: @@ -317,7 +317,7 @@ void gst_buffer_resize (GstBuffer *buffer, gssize offset, gs /* 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 */ /** diff --git a/gst/gstmemory.c b/gst/gstmemory.c index e709396011..b2ac925929 100644 --- a/gst/gstmemory.c +++ b/gst/gstmemory.c @@ -278,7 +278,7 @@ _default_mem_is_span (GstMemoryDefault * mem1, GstMemoryDefault * mem2, } static GstMemory * -_fallback_copy (GstMemory * mem, gssize offset, gsize size) +_fallback_copy (GstMemory * mem, gssize offset, gssize size) { GstMemory *copy; guint8 *data, *dest; @@ -465,7 +465,7 @@ gst_memory_map (GstMemory * mem, gsize * size, gsize * maxsize, * 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 @@ -474,7 +474,7 @@ gst_memory_map (GstMemory * mem, gsize * size, gsize * maxsize, * 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); @@ -485,7 +485,7 @@ gst_memory_unmap (GstMemory * mem, gpointer data, gsize size) * 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 @@ -494,7 +494,7 @@ gst_memory_unmap (GstMemory * mem, gpointer data, gsize size) * 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); @@ -505,17 +505,17 @@ gst_memory_copy (GstMemory * mem, gssize offset, gsize size) * 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); diff --git a/gst/gstmemory.h b/gst/gstmemory.h index c4d618706f..9215e47cc3 100644 --- a/gst/gstmemory.h +++ b/gst/gstmemory.h @@ -143,7 +143,7 @@ typedef gsize (*GstMemoryGetSizesFunction) (GstMemory *mem, gsize *offset * 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 @@ -151,7 +151,7 @@ typedef gsize (*GstMemoryGetSizesFunction) (GstMemory *mem, gsize *offset * * @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: @@ -175,7 +175,7 @@ typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize *size, * 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 @@ -183,7 +183,7 @@ typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize *size, * * Returns: %TRUE on success. */ -typedef gboolean (*GstMemoryUnmapFunction) (GstMemory *mem, gpointer data, gsize size); +typedef gboolean (*GstMemoryUnmapFunction) (GstMemory *mem, gpointer data, gssize size); /** * GstMemoryFreeFunction: @@ -198,7 +198,7 @@ typedef void (*GstMemoryFreeFunction) (GstMemory *mem); * 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. @@ -207,13 +207,13 @@ typedef void (*GstMemoryFreeFunction) (GstMemory *mem); * 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 @@ -221,7 +221,7 @@ typedef GstMemory * (*GstMemoryCopyFunction) (GstMemory *mem, gssize offset * * 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: @@ -291,11 +291,11 @@ void gst_memory_resize (GstMemory *mem, gssize offset, gsize size); /* 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);