buffer: Only set TAG_MEMORY if the memory has been replaced

Currently we set TAG_MEMORY as soon a resize changes the size of one
of the memory. This has the side effect that buffer pool cannot know if
the memory have simply been resized, or if the memorys has been replaced.
This make it hard to actually implement _reset(). Instead, only set the
TAG_MEMORY if one or more memory has been replaced, and do a light
sanity check of the size.

https://bugzilla.gnome.org/show_bug.cgi?id=727109
This commit is contained in:
Nicolas Dufresne 2014-03-26 15:56:08 -04:00
parent d17438d5fd
commit ec69ad4e8a
2 changed files with 6 additions and 1 deletions

View file

@ -1462,8 +1462,8 @@ gst_buffer_resize_range (GstBuffer * buffer, guint idx, gint length,
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_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
offset = noffs;

View file

@ -1140,6 +1140,11 @@ default_release_buffer (GstBufferPool * pool, GstBuffer * buffer)
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY))
goto discard;
/* size should have been reset. This is not a catch all, pool with
* size requirement per memory should do their own check. */
if (gst_buffer_get_size (buffer) != pool->priv->size)
goto discard;
/* all memory should be exclusive to this buffer (and thus be writable) */
if (!gst_buffer_is_all_memory_writable (buffer))
goto discard;