diff options
author | Petr Kulhavy <brain@jikos.cz> | 2016-11-14 15:35:50 +0100 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2018-03-21 17:50:30 -0400 |
commit | 7d75d3ef4181de6658fe7d4dbbe633082257315d (patch) | |
tree | 1df5e7bd6a56775636fe82a9a110c21ff5ff1313 | |
parent | 29e81988fbdb56391d6b99e9195a74695a9a875f (diff) | |
download | gstreamer-7d75d3ef4181de6658fe7d4dbbe633082257315d.tar.gz |
gstbuffer: reset buffer to its original size if intact
Enhance default_reset_buffer() to resize the buffer to its full size if the
memory hasn't changed. This allows to reuse the buffer even if the offset has
changed or the size has shrunk, rather than freeing the buffer.
Change related to: https://bugzilla.gnome.org/show_bug.cgi?id=772841
-rw-r--r-- | gst/gstbufferpool.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gst/gstbufferpool.c b/gst/gstbufferpool.c index 3d9123621b..6db0f5d2cc 100644 --- a/gst/gstbufferpool.c +++ b/gst/gstbufferpool.c @@ -1226,6 +1226,10 @@ default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer) GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE; GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE; + /* if the memory is intact reset the size to the full size */ + if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY)) + gst_buffer_resize (buffer, 0, pool->priv->size); + /* remove all metadata without the POOLED flag */ gst_buffer_foreach_meta (buffer, remove_meta_unpooled, pool); } |