* the refcount drops to 0, any memory and metadata pointed to by the buffer is
* unreffed as well. Buffers allocated from a #GstBufferPool will be returned to
* the pool when the refcount drops to 0.
- *
- * Last reviewed on 2012-03-28 (0.11.3)
*/
#include "gst_private.h"
&GST_BUFFER_MEM_PTR (buffer, end), (len - end) * sizeof (gpointer));
}
GST_BUFFER_MEM_LEN (buffer) = len - length;
- GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
static inline void
GST_BUFFER_MEM_PTR (buffer, idx) = mem;
GST_BUFFER_MEM_LEN (buffer) = len + 1;
- GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
GST_DEFINE_MINI_OBJECT_TYPE (GstBuffer, gst_buffer);
if (!gst_buffer_copy_into (copy, buffer, GST_BUFFER_COPY_ALL, 0, -1))
gst_buffer_replace (©, NULL);
- GST_BUFFER_FLAG_SET (copy, GST_BUFFER_FLAG_TAG_MEMORY);
+ if (copy)
+ GST_BUFFER_FLAG_UNSET (copy, GST_BUFFER_FLAG_TAG_MEMORY);
return copy;
}
/**
* gst_buffer_new_allocate:
- * @allocator: (transfer none) (allow-none): the #GstAllocator to use, or NULL to use the
+ * @allocator: (transfer none) (allow-none): the #GstAllocator to use, or %NULL to use the
* default allocator
* @size: the size in bytes of the new buffer's data.
* @params: (transfer none) (allow-none): optional parameters
*
* Tries to create a newly allocated buffer with data of the given size and
* extra parameters from @allocator. If the requested amount of memory can't be
- * allocated, NULL will be returned. The allocated buffer memory is not cleared.
+ * allocated, %NULL will be returned. The allocated buffer memory is not cleared.
*
- * When @allocator is NULL, the default memory allocator will be used.
+ * When @allocator is %NULL, the default memory allocator will be used.
*
* Note that when @size == 0, the buffer will not have memory associated with it.
*
* MT safe.
*
- * Returns: (transfer full): a new #GstBuffer, or NULL if the memory couldn't
+ * Returns: (transfer full): a new #GstBuffer, or %NULL if the memory couldn't
* be allocated.
*/
GstBuffer *
if (size > 0)
_memory_add (newbuf, -1, gst_memory_ref (mem), TRUE);
#endif
- GST_BUFFER_FLAG_SET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
+ GST_BUFFER_FLAG_UNSET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
return newbuf;
gst_memory_new_wrapped (flags, data, maxsize, offset, size, user_data,
notify);
_memory_add (newbuf, -1, mem, TRUE);
- GST_BUFFER_FLAG_SET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
+ GST_BUFFER_FLAG_UNSET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
return newbuf;
}
GST_BUFFER_MEM_PTR (buffer, idx) = mapped;
/* unlock old memory */
gst_memory_unlock (mem, GST_LOCK_FLAG_EXCLUSIVE);
- GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
gst_memory_unref (mem);
{
guint i, len;
- g_return_if_fail (GST_IS_BUFFER (buffer));
+ g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
GST_CAT_DEBUG (GST_CAT_BUFFER, "idx %u, length %d", idx, length);
len = GST_BUFFER_MEM_LEN (buffer);
- g_return_if_fail ((len == 0 && idx == 0 && length == -1) ||
- (length == -1 && idx < len) || (length > 0 && length + idx <= len));
+ g_return_val_if_fail ((len == 0 && idx == 0 && length == -1) ||
+ (length == -1 && idx < len) || (length > 0 && length + idx <= len),
+ FALSE);
if (length == -1)
- length = len - idx;
+ len -= idx;
+ else
+ len = length;
for (i = 0; i < len; i++) {
- if (!gst_memory_is_writable (GST_BUFFER_MEM_PTR (buffer, i)))
+ if (!gst_memory_is_writable (GST_BUFFER_MEM_PTR (buffer, i + idx)))
return FALSE;
}
return TRUE;
gst_memory_unlock (mem, GST_LOCK_FLAG_EXCLUSIVE);
gst_memory_unref (mem);
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
- GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
offset = noffs;
{
GST_WARNING_OBJECT (buffer, "write map requested on non-writable buffer");
g_critical ("write map requested on non-writable buffer");
+ memset (info, 0, sizeof (GstMapInfo));
return FALSE;
}
no_memory:
{
/* empty buffer, we need to return NULL */
GST_DEBUG_OBJECT (buffer, "can't get buffer memory");
- info->memory = NULL;
- info->data = NULL;
- info->size = 0;
- info->maxsize = 0;
+ memset (info, 0, sizeof (GstMapInfo));
return TRUE;
}
cannot_map:
{
GST_DEBUG_OBJECT (buffer, "cannot map memory");
+ memset (info, 0, sizeof (GstMapInfo));
return FALSE;
}
}
*
* MT safe.
*
- * Returns: (transfer full): the new #GstBuffer or NULL if the arguments were
+ * Returns: (transfer full): the new #GstBuffer or %NULL if the arguments were
* invalid.
*/
GstBuffer *
}
GST_BUFFER_MEM_LEN (buf2) = 0;
- GST_BUFFER_FLAG_UNSET (buf2, GST_BUFFER_FLAG_TAG_MEMORY);
+ GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_TAG_MEMORY);
gst_buffer_unref (buf2);
return buf1;
* @api: the #GType of an API
*
* Get the metadata for @api on buffer. When there is no such
- * metadata, NULL is returned.
+ * metadata, %NULL is returned.
*
* Returns: (transfer none): the metadata for @api on @buffer.
*/