Commit 38ffe307 authored by Wim Taymans's avatar Wim Taymans

memory: more work on implementing buffer memory

parent 1af328e7
......@@ -196,7 +196,7 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
#if GST_VERSION_NANO == 1
/* we enable this extra debugging in git versions only for now */
g_warn_if_fail (gst_buffer_is_metadata_writable (dest));
g_warn_if_fail (gst_buffer_is_writable (dest));
#endif
GST_CAT_LOG (GST_CAT_BUFFER, "copy %p to %p", src, dest);
......@@ -398,8 +398,10 @@ gst_buffer_new_and_alloc (guint size)
newbuf = gst_buffer_new ();
gst_buffer_take_memory (newbuf, gst_memory_new_alloc (size,
_gst_buffer_data_alignment));
if (size > 0) {
gst_buffer_take_memory (newbuf, gst_memory_new_alloc (size,
_gst_buffer_data_alignment));
}
GST_CAT_LOG (GST_CAT_BUFFER, "new %p of size %d", newbuf, size);
......@@ -429,24 +431,39 @@ gst_buffer_try_new_and_alloc (guint size)
GstBuffer *newbuf;
GstMemory *mem;
mem = gst_memory_new_alloc (size, _gst_buffer_data_alignment);
if (G_UNLIKELY (mem == NULL)) {
GST_CAT_WARNING (GST_CAT_BUFFER, "failed to allocate %d bytes", size);
return NULL;
if (size > 0) {
mem = gst_memory_new_alloc (size, _gst_buffer_data_alignment);
if (G_UNLIKELY (mem == NULL))
goto no_memory;
} else {
mem = NULL;
}
newbuf = gst_buffer_new ();
gst_buffer_take_memory (newbuf, mem);
if (mem != NULL)
gst_buffer_take_memory (newbuf, mem);
GST_CAT_LOG (GST_CAT_BUFFER, "new %p of size %d", newbuf, size);
return newbuf;
/* ERRORS */
no_memory:
{
GST_CAT_WARNING (GST_CAT_BUFFER, "failed to allocate %d bytes", size);
return NULL;
}
}
guint
gst_buffer_n_memory (GstBuffer * buffer)
{
GPtrArray *arr = (GPtrArray *) buffer->memory;
GPtrArray *arr;
g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
arr = (GPtrArray *) buffer->memory;
return arr->len;
}
......@@ -454,8 +471,13 @@ gst_buffer_n_memory (GstBuffer * buffer)
void
gst_buffer_take_memory (GstBuffer * buffer, GstMemory * mem)
{
GPtrArray *arr = (GPtrArray *) buffer->memory;
GPtrArray *arr;
g_return_if_fail (GST_IS_BUFFER (buffer));
g_return_if_fail (gst_buffer_is_writable (buffer));
g_return_if_fail (mem != NULL);
arr = (GPtrArray *) buffer->memory;
g_ptr_array_add (arr, mem);
}
......@@ -463,7 +485,11 @@ GstMemory *
gst_buffer_peek_memory (GstBuffer * buffer, guint idx)
{
GstMemory *mem;
GPtrArray *arr = (GPtrArray *) buffer->memory;
GPtrArray *arr;
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
arr = (GPtrArray *) buffer->memory;
g_return_val_if_fail (idx < arr->len, NULL);
mem = g_ptr_array_index (arr, idx);
......@@ -473,7 +499,12 @@ gst_buffer_peek_memory (GstBuffer * buffer, guint idx)
void
gst_buffer_remove_memory (GstBuffer * buffer, guint idx)
{
GPtrArray *arr = (GPtrArray *) buffer->memory;
GPtrArray *arr;
g_return_if_fail (GST_IS_BUFFER (buffer));
g_return_if_fail (gst_buffer_is_writable (buffer));
arr = (GPtrArray *) buffer->memory;
g_return_if_fail (idx < arr->len);
g_ptr_array_remove_index (arr, idx);
}
......@@ -484,6 +515,8 @@ gst_buffer_get_size (GstBuffer * buffer)
GPtrArray *arr = (GPtrArray *) buffer->memory;
guint i, size, len;
g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
len = arr->len;
size = 0;
......@@ -498,29 +531,53 @@ gpointer
gst_buffer_map (GstBuffer * buffer, gsize * size, gsize * maxsize,
GstMapFlags flags)
{
GPtrArray *arr = (GPtrArray *) buffer->memory;
GPtrArray *arr;
guint len;
gpointer data;
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
arr = (GPtrArray *) buffer->memory;
len = arr->len;
if (G_UNLIKELY ((flags & GST_MAP_WRITE) && !gst_buffer_is_writable (buffer)))
goto not_writable;
if (G_LIKELY (len == 1)) {
GstMemory *mem = g_ptr_array_index (arr, 0);
if (flags & GST_MAP_WRITE) {
if (G_UNLIKELY (!GST_MEMORY_IS_WRITABLE (mem))) {
/* try to get a writable copy */
g_return_val_if_fail (GST_MEMORY_IS_WRITABLE (mem), NULL);
return NULL;
}
}
data = gst_memory_map (mem, size, maxsize, flags);
} else {
data = NULL;
}
return data;
/* ERROR */
not_writable:
{
g_return_val_if_fail (gst_buffer_is_writable (buffer), NULL);
return NULL;
}
}
gboolean
gst_buffer_unmap (GstBuffer * buffer, gpointer data, gsize size)
{
GPtrArray *arr = (GPtrArray *) buffer->memory;
GPtrArray *arr;
gboolean result;
guint len;
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
arr = (GPtrArray *) buffer->memory;
len = arr->len;
if (G_LIKELY (len == 1)) {
......@@ -611,62 +668,13 @@ gst_buffer_set_caps (GstBuffer * buffer, GstCaps * caps)
#if GST_VERSION_NANO == 1
/* we enable this extra debugging in git versions only for now */
g_warn_if_fail (gst_buffer_is_metadata_writable (buffer));
g_warn_if_fail (gst_buffer_is_writable (buffer));
/* FIXME: would be nice to also check if caps are fixed here, but expensive */
#endif
gst_caps_replace (&GST_BUFFER_CAPS (buffer), caps);
}
/**
* gst_buffer_is_metadata_writable:
* @buf: a #GstBuffer
*
* Similar to gst_buffer_is_writable, but this only ensures that the
* refcount of the buffer is 1, indicating that the caller is the sole
* owner and can change the buffer metadata, such as caps and timestamps.
*
* Returns: TRUE if the metadata is writable.
*/
gboolean
gst_buffer_is_metadata_writable (GstBuffer * buf)
{
return (GST_MINI_OBJECT_REFCOUNT_VALUE (GST_MINI_OBJECT_CAST (buf)) == 1);
}
/**
* gst_buffer_make_metadata_writable:
* @buf: (transfer full): a #GstBuffer
*
* Similar to gst_buffer_make_writable, but does not ensure that the buffer
* data array is writable. Instead, this just ensures that the returned buffer
* is solely owned by the caller, by creating a subbuffer of the original
* buffer if necessary.
*
* After calling this function, @buf should not be referenced anymore. The
* result of this function has guaranteed writable metadata.
*
* Returns: (transfer full): a new #GstBuffer with writable metadata, which
* may or may not be the same as @buf.
*/
GstBuffer *
gst_buffer_make_metadata_writable (GstBuffer * buf)
{
GstBuffer *ret;
if (gst_buffer_is_metadata_writable (buf)) {
ret = buf;
} else {
/* create a fresh new buffer */
ret = gst_buffer_new ();
/* we simply copy everything from our parent */
gst_buffer_copy_into (ret, buf, GST_BUFFER_COPY_ALL, 0, 0);
gst_buffer_unref (buf);
}
return ret;
}
/**
* gst_buffer_create_sub:
* @parent: a #GstBuffer.
......
......@@ -202,7 +202,6 @@ typedef struct _GstBufferPool GstBufferPool;
/**
* GstBufferFlag:
* @GST_BUFFER_FLAG_READONLY: the buffer is read-only. This means the data of
* the buffer should not be modified. The metadata might still be modified.
* @GST_BUFFER_FLAG_PREROLL: the buffer is part of a preroll and should not be
* displayed.
......@@ -223,7 +222,6 @@ typedef struct _GstBufferPool GstBufferPool;
* A set of buffer flags used to describe properties of a #GstBuffer.
*/
typedef enum {
GST_BUFFER_FLAG_READONLY = GST_MINI_OBJECT_FLAG_READONLY,
GST_BUFFER_FLAG_PREROLL = (GST_MINI_OBJECT_FLAG_LAST << 0),
GST_BUFFER_FLAG_DISCONT = (GST_MINI_OBJECT_FLAG_LAST << 1),
GST_BUFFER_FLAG_IN_CAPS = (GST_MINI_OBJECT_FLAG_LAST << 2),
......@@ -456,11 +454,6 @@ void gst_buffer_copy_into (GstBuffer *dest, GstBuffer *src
*/
#define gst_buffer_make_writable(buf) GST_BUFFER_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (buf)))
/* Ensure that the metadata of the buffer is writable, even if the buffer data
* isn't */
gboolean gst_buffer_is_metadata_writable (GstBuffer *buf);
GstBuffer* gst_buffer_make_metadata_writable (GstBuffer *buf);
/**
* gst_buffer_replace:
* @obuf: (inout) (transfer full): pointer to a pointer to a #GstBuffer to be
......
......@@ -47,12 +47,12 @@ static const GstMemoryImpl *_default_mem_impl;
static const GstMemoryImpl *_default_sub_impl;
static void
_default_mem_init (GstMemoryDefault * mem, GstMemory * parent,
gsize slice_size, gpointer data, GFreeFunc free_func,
gsize maxsize, gsize offset, gsize size)
_default_mem_init (GstMemoryDefault * mem, GstMemoryFlags flags,
GstMemory * parent, gsize slice_size, gpointer data,
GFreeFunc free_func, gsize maxsize, gsize offset, gsize size)
{
mem->mem.impl = data ? _default_mem_impl : _default_sub_impl;
mem->mem.flags = 0;
mem->mem.flags = flags;
mem->mem.refcount = 1;
mem->mem.parent = parent ? gst_memory_ref (parent) : NULL;
mem->slice_size = slice_size;
......@@ -64,7 +64,7 @@ _default_mem_init (GstMemoryDefault * mem, GstMemory * parent,
}
static GstMemoryDefault *
_default_mem_new (GstMemory * parent, gpointer data,
_default_mem_new (GstMemoryFlags flags, GstMemory * parent, gpointer data,
GFreeFunc free_func, gsize maxsize, gsize offset, gsize size)
{
GstMemoryDefault *mem;
......@@ -73,7 +73,7 @@ _default_mem_new (GstMemory * parent, gpointer data,
slice_size = sizeof (GstMemoryDefault);
mem = g_slice_alloc (slice_size);
_default_mem_init (mem, parent, slice_size,
_default_mem_init (mem, flags, parent, slice_size,
data, free_func, maxsize, offset, size);
return mem;
......@@ -98,7 +98,7 @@ _default_mem_new_block (gsize maxsize, gsize align, gsize offset, gsize size)
if ((aoffset = ((guintptr) data & align)))
aoffset = align - aoffset;
_default_mem_init (mem, NULL, slice_size, data, NULL, maxsize + align,
_default_mem_init (mem, 0, NULL, slice_size, data, NULL, maxsize + align,
aoffset + offset, size);
return mem;
......@@ -213,7 +213,7 @@ _default_mem_sub (GstMemoryDefault * mem, gsize offset, gsize size)
if ((parent = mem->mem.parent) == NULL)
parent = (GstMemory *) mem;
sub = _default_mem_new (parent, mem->data, NULL, mem->maxsize,
sub = _default_mem_new (parent->flags, parent, mem->data, NULL, mem->maxsize,
mem->offset + offset, size);
return sub;
......@@ -265,7 +265,7 @@ _fallback_sub (GstMemory * mem, gsize offset, gsize size)
/* find the real parent */
parent = mem->parent ? mem->parent : mem;
sub = _default_mem_new (parent, NULL, NULL, size, offset, size);
sub = _default_mem_new (0, parent, NULL, NULL, size, offset, size);
return (GstMemory *) sub;
}
......@@ -458,7 +458,11 @@ gst_memory_is_span (GstMemory ** mem1, gsize len1, GstMemory ** mem2,
return FALSE;
if (!have_offset) {
*offset = offs;
if (offset)
*offset = offs;
if (parent)
*parent = m1->parent;
have_offset = TRUE;
}
}
......@@ -517,12 +521,12 @@ gst_memory_span (GstMemory ** mem1, gsize len1, gsize offset, GstMemory ** mem2,
}
GstMemory *
gst_memory_new_wrapped (gpointer data, GFreeFunc free_func,
gsize maxsize, gsize offset, gsize size)
gst_memory_new_wrapped (GstMemoryFlags flags, gpointer data,
GFreeFunc free_func, gsize maxsize, gsize offset, gsize size)
{
GstMemoryDefault *mem;
mem = _default_mem_new (NULL, data, free_func, maxsize, offset, size);
mem = _default_mem_new (flags, NULL, data, free_func, maxsize, offset, size);
return (GstMemory *) mem;
}
......@@ -532,7 +536,7 @@ gst_memory_new_alloc (gsize maxsize, gsize align)
{
GstMemoryDefault *mem;
mem = _default_mem_new_block (maxsize, align, 0, 0);
mem = _default_mem_new_block (maxsize, align, 0, maxsize);
return (GstMemory *) mem;
}
......
......@@ -34,10 +34,14 @@ typedef struct _GstMemoryInfo GstMemoryInfo;
typedef struct _GstMemoryImpl GstMemoryImpl;
typedef enum {
GST_MEMORY_FLAG_READONLY = (1 << 0),
GST_MEMORY_FLAG_MUTABLE = (1 << 1),
GST_MEMORY_FLAG_READONLY = (1 << 0)
} GstMemoryFlags;
#define GST_MEMORY_IS_WRITABLE(mem) (((mem)->refcount == 1) && \
(((mem)->parent == NULL) || ((mem)->parent->refcount == 1)) && \
(((mem)->flags & GST_MEMORY_FLAG_READONLY) == 0))
/**
* GstMemory:
* @impl: pointer to the #GstMemoryImpl
......@@ -104,7 +108,7 @@ struct _GstMemoryInfo {
void _gst_memory_init (void);
/* allocating memory blocks */
GstMemory * gst_memory_new_wrapped (gpointer data, GFreeFunc free_func,
GstMemory * gst_memory_new_wrapped (GstMemoryFlags flags, gpointer data, GFreeFunc free_func,
gsize maxsize, gsize offset, gsize size);
GstMemory * gst_memory_new_alloc (gsize maxsize, gsize align);
GstMemory * gst_memory_new_copy (gsize maxsize, gsize align, gpointer data,
......
......@@ -154,8 +154,7 @@ gst_mini_object_is_writable (const GstMiniObject * mini_object)
{
g_return_val_if_fail (mini_object != NULL, FALSE);
return (GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) == 1) &&
((mini_object->flags & GST_MINI_OBJECT_FLAG_READONLY) == 0);
return (GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) == 1);
}
/**
......
......@@ -106,14 +106,12 @@ typedef void (*GstMiniObjectFreeFunction) (GstMiniObject *obj);
/**
* GstMiniObjectFlags:
* @GST_MINI_OBJECT_FLAG_READONLY: is the miniobject readonly or writable
* @GST_MINI_OBJECT_FLAG_LAST: first flag that can be used by subclasses.
*
* Flags for the mini object
*/
typedef enum
{
GST_MINI_OBJECT_FLAG_READONLY = (1<<0),
/* padding */
GST_MINI_OBJECT_FLAG_LAST = (1<<4)
} GstMiniObjectFlags;
......
......@@ -736,8 +736,8 @@ gst_adapter_take_buffer (GstAdapter * adapter, gsize nbytes)
data = gst_adapter_take_internal (adapter, nbytes);
buffer = gst_buffer_new ();
gst_buffer_take_memory (buffer, gst_memory_new_wrapped (data, g_free, nbytes,
0, nbytes));
gst_buffer_take_memory (buffer,
gst_memory_new_wrapped (0, data, g_free, nbytes, 0, nbytes));
done:
gst_adapter_flush_unchecked (adapter, nbytes);
......
......@@ -2153,13 +2153,13 @@ again:
/* no timestamp set and we are at offset 0, we can timestamp with 0 */
if (offset == 0 && src->segment.time == 0
&& GST_BUFFER_TIMESTAMP (*buf) == -1) {
*buf = gst_buffer_make_metadata_writable (*buf);
*buf = gst_buffer_make_writable (*buf);
GST_BUFFER_TIMESTAMP (*buf) = 0;
}
/* set pad caps on the buffer if the buffer had no caps */
if (GST_BUFFER_CAPS (*buf) == NULL) {
*buf = gst_buffer_make_metadata_writable (*buf);
*buf = gst_buffer_make_writable (*buf);
gst_buffer_set_caps (*buf, GST_PAD_CAPS (src->srcpad));
}
......@@ -2499,7 +2499,7 @@ gst_base_src_loop (GstPad * pad)
}
if (G_UNLIKELY (src->priv->discont)) {
buf = gst_buffer_make_metadata_writable (buf);
buf = gst_buffer_make_writable (buf);
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
src->priv->discont = FALSE;
}
......
......@@ -1459,7 +1459,7 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
if (othercaps && !gst_caps_is_empty (othercaps)) {
GST_DEBUG_OBJECT (trans, "we found target caps %" GST_PTR_FORMAT,
othercaps);
*out_buf = gst_buffer_make_metadata_writable (*out_buf);
*out_buf = gst_buffer_make_writable (*out_buf);
gst_buffer_set_caps (*out_buf, othercaps);
gst_caps_unref (othercaps);
newcaps = GST_BUFFER_CAPS (*out_buf);
......@@ -1487,7 +1487,7 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
GST_DEBUG_PAD_NAME (trans->srcpad));
bclass->fixate_caps (trans, GST_PAD_SINK, incaps, newcaps);
*out_buf = gst_buffer_make_metadata_writable (*out_buf);
*out_buf = gst_buffer_make_writable (*out_buf);
gst_buffer_set_caps (*out_buf, newcaps);
gst_caps_unref (newcaps);
newcaps = GST_BUFFER_CAPS (*out_buf);
......@@ -1596,12 +1596,12 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
if (setcaps || copymeta) {
GST_DEBUG_OBJECT (trans, "setcaps %d, copymeta %d", setcaps, copymeta);
if (!gst_buffer_is_metadata_writable (*out_buf)) {
if (!gst_buffer_is_writable (*out_buf)) {
GST_DEBUG_OBJECT (trans, "buffer metadata %p not writable", *out_buf);
if (in_buf == *out_buf)
*out_buf = gst_buffer_create_sub (in_buf, 0, insize);
else
*out_buf = gst_buffer_make_metadata_writable (*out_buf);
*out_buf = gst_buffer_make_writable (*out_buf);
}
/* when we get here, the metadata should be writable */
if (setcaps)
......@@ -2436,7 +2436,7 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer)
/* apply DISCONT flag if the buffer is not yet marked as such */
if (trans->priv->discont) {
if (!GST_BUFFER_IS_DISCONT (outbuf)) {
outbuf = gst_buffer_make_metadata_writable (outbuf);
outbuf = gst_buffer_make_writable (outbuf);
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
}
trans->priv->discont = FALSE;
......
......@@ -259,8 +259,8 @@ gst_byte_writer_reset_and_get_buffer (GstByteWriter * writer)
data = gst_byte_writer_reset_and_get_data (writer);
buffer = gst_buffer_new ();
gst_buffer_take_memory (buffer, gst_memory_new_wrapped (data, g_free, size, 0,
size));
gst_buffer_take_memory (buffer,
gst_memory_new_wrapped (0, data, g_free, size, 0, size));
return buffer;
}
......
......@@ -334,7 +334,7 @@ gst_capsfilter_prepare_buf (GstBaseTransform * trans, GstBuffer * input,
if (GST_BUFFER_CAPS (input) != caps) {
/* caps are different, make a metadata writable output buffer to set
* caps */
if (gst_buffer_is_metadata_writable (input)) {
if (gst_buffer_is_writable (input)) {
/* input is writable, just set caps and use this as the output */
*buf = input;
gst_buffer_set_caps (*buf, caps);
......@@ -368,7 +368,7 @@ gst_capsfilter_prepare_buf (GstBaseTransform * trans, GstBuffer * input,
if (gst_caps_is_fixed (out_caps) && !gst_caps_is_empty (out_caps)) {
GST_DEBUG_OBJECT (trans, "Have fixed output caps %"
GST_PTR_FORMAT " to apply to buffer with no caps", out_caps);
if (gst_buffer_is_metadata_writable (input)) {
if (gst_buffer_is_writable (input)) {
gst_buffer_ref (input);
*buf = input;
} else {
......
......@@ -691,8 +691,8 @@ gst_fake_src_alloc_buffer (GstFakeSrc * src, guint size)
if (do_prepare)
gst_fake_src_prepare_buffer (src, data, size);
gst_buffer_take_memory (buf, gst_memory_new_wrapped (data, g_free, size, 0,
size));
gst_buffer_take_memory (buf,
gst_memory_new_wrapped (0, data, g_free, size, 0, size));
}
return buf;
......
......@@ -394,13 +394,13 @@ gst_identity_prepare_output_buffer (GstBaseTransform * trans,
/* only bother if we may have to alter metadata */
if (identity->datarate > 0 || identity->single_segment) {
if (gst_buffer_is_metadata_writable (in_buf))
if (gst_buffer_is_writable (in_buf))
*out_buf = gst_buffer_ref (in_buf);
else {
/* make even less writable */
gst_buffer_ref (in_buf);
/* extra ref is dropped going through the official process */
*out_buf = gst_buffer_make_metadata_writable (in_buf);
*out_buf = gst_buffer_make_writable (in_buf);
}
} else
*out_buf = gst_buffer_ref (in_buf);
......
......@@ -659,7 +659,7 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf)
gst_pad_push_event (sel->srcpad, start_event);
if (selpad->discont) {
buf = gst_buffer_make_metadata_writable (buf);
buf = gst_buffer_make_writable (buf);
GST_DEBUG_OBJECT (pad, "Marking discont buffer %p", buf);
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
......
......@@ -1008,7 +1008,7 @@ gst_queue_chain (GstPad * pad, GstBuffer * buffer)
}
if (queue->tail_needs_discont) {
GstBuffer *subbuffer = gst_buffer_make_metadata_writable (buffer);
GstBuffer *subbuffer = gst_buffer_make_writable (buffer);
if (subbuffer) {
buffer = subbuffer;
......@@ -1109,7 +1109,7 @@ next:
buffer = GST_BUFFER_CAST (data);
if (queue->head_needs_discont) {
GstBuffer *subbuffer = gst_buffer_make_metadata_writable (buffer);
GstBuffer *subbuffer = gst_buffer_make_writable (buffer);
if (subbuffer) {
buffer = subbuffer;
......
......@@ -488,7 +488,7 @@ stop_typefinding (GstTypeFindElement * typefind)
goto no_data;
buffer = gst_adapter_take_buffer (typefind->adapter, avail);
buffer = gst_buffer_make_metadata_writable (buffer);
buffer = gst_buffer_make_writable (buffer);
gst_buffer_set_caps (buffer, typefind->caps);
GST_OBJECT_UNLOCK (typefind);
......@@ -636,7 +636,7 @@ gst_type_find_element_setcaps (GstPad * pad, GstCaps * caps)
goto no_data;
buffer = gst_adapter_take_buffer (typefind->adapter, avail);
buffer = gst_buffer_make_metadata_writable (buffer);
buffer = gst_buffer_make_writable (buffer);
gst_buffer_set_caps (buffer, typefind->caps);
GST_OBJECT_UNLOCK (typefind);
......@@ -752,7 +752,7 @@ gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
return GST_FLOW_ERROR;
case MODE_NORMAL:
/* don't take object lock as typefind->caps should not change anymore */
buffer = gst_buffer_make_metadata_writable (buffer);
buffer = gst_buffer_make_writable (buffer);
gst_buffer_set_caps (buffer, typefind->caps);
return gst_pad_push (typefind->src, buffer);
case MODE_TYPEFIND:
......
......@@ -182,7 +182,7 @@ gst_valve_chain (GstPad * pad, GstBuffer * buffer)
valve->discont = TRUE;
} else {
if (valve->discont) {
buffer = gst_buffer_make_metadata_writable (buffer);
buffer = gst_buffer_make_writable (buffer);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
valve->discont = FALSE;
}
......
......@@ -86,7 +86,7 @@ GST_START_TEST (test_subbuffer)
/* check sizes, buffer starts out empty */
data = gst_buffer_map (buffer, &size, &maxsize, GST_MAP_WRITE);
fail_unless (size == 0, "buffer has wrong size");
fail_unless (size == 4, "buffer has wrong size");
fail_unless (maxsize >= 4, "buffer has wrong size");
memset (data, 0, 4);
gst_buffer_unmap (buffer, data, 4);
......@@ -105,7 +105,6 @@ GST_START_TEST (test_subbuffer)
fail_unless (ssize == 2, "subbuffer has wrong size");
fail_unless (memcmp (data + 1, sdata, 2) == 0,
"subbuffer contains the wrong data");
ASSERT_BUFFER_REFCOUNT (buffer, "parent", 2);
ASSERT_BUFFER_REFCOUNT (sub, "subbuffer", 1);
fail_unless (GST_BUFFER_TIMESTAMP (sub) == -1,
"subbuffer has wrong timestamp");
......@@ -123,7 +122,6 @@ GST_START_TEST (test_subbuffer)
fail_unless (ssize == 0, "subbuffer has wrong size");
fail_unless (memcmp (data + 1, sdata, 0) == 0,
"subbuffer contains the wrong data");
ASSERT_BUFFER_REFCOUNT (buffer, "parent", 2);
ASSERT_BUFFER_REFCOUNT (sub, "subbuffer", 1);
gst_buffer_unmap (sub, sdata, ssize);
gst_buffer_unref (sub);
......@@ -293,11 +291,10 @@ create_read_only_buffer (void)