Commit graph

9 commits

Author SHA1 Message Date
Xavier Claessens 096bd3c4a2 gstbuffer: Add parent meta when a copy shares memory with parent
When copying a buffer, for example with gst_buffer_make_writable(), the
new buffer might reference the same GstMemory as the src buffer,
making those memories not writable. If the src buffer gets disposed
first it should return to its buffer pool, but since some of its
memories are not writable it gets discarded and new buffer/memory gets
allocated.

Solves this by making the new buffer keep a reference to the src buffer,
that ensures that by the time the src buffer gets disposed no other
buffer are referencing its memories and it can thus return safely to its
pool.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4176>
2023-03-16 00:03:11 +00:00
Xavier Claessens 22613b9baf gstbuffer: Unref memories before metas
gst_buffer_add_parent_buffer_meta() is used when a GstBuffer uses
GstMemory from another buffer that was allocated from a pool. In that
case we want to make sure the buffer returns to the pool when the memory
is writable again, otherwise a copy of the memory is created. That means
the child buffer must drop its ref to the memory first, then drop the
ref to parent buffer so it can return to the pool when it is the only
owner of the memory.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4176>
2023-03-16 00:03:11 +00:00
James Hilliard 1f1e7a3d99 buffer: fix copy meta reference debug log formatting
Fixes the following valgrind error:
==616== Conditional jump or move depends on uninitialised value(s)
==616==    at 0x4900E34: gst_debug_print_object (gstinfo.c:1143)
==616==    by 0x49010B6: gst_info_printf_pointer_extension_func (gstinfo.c:1215)
==616==    by 0x4959FDB: __gst_printf_pointer_extension_serialize (printf-extension.c:47)
==616==    by 0x495A487: printf_postprocess_args (vasnprintf.c:258)
==616==    by 0x495A52C: __gst_vasnprintf (vasnprintf.c:290)
==616==    by 0x4959F8F: __gst_vasprintf (printf.c:154)
==616==    by 0x4901C1F: gst_debug_message_get (gstinfo.c:791)
==616==    by 0x4901C75: _gst_debug_log_preamble (gstinfo.c:1431)
==616==    by 0x4903208: gst_debug_log_default (gstinfo.c:1575)
==616==    by 0x49020BA: gst_debug_log_full_valist (gstinfo.c:624)
==616==    by 0x490211D: gst_debug_log_valist (gstinfo.c:656)
==616==    by 0x49021AD: gst_debug_log (gstinfo.c:533)
==616==    by 0x48DDC11: gst_buffer_copy_into (gstbuffer.c:693)
==616==    by 0x48DF5F1: gst_buffer_copy_with_flags (gstbuffer.c:727)
==616==    by 0x48DF640: gst_buffer_copy_deep (gstbuffer.c:756)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4034>
2023-02-21 20:14:00 -07:00
Tim-Philipp Müller 25f7fa1efc allocator, buffer, bufferlist: drop use of GSlice
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3695>
2023-01-24 15:25:05 +00:00
Hugo Svirak 4aeb3def20 docs: specify possibility of a NULL return
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3546>
2022-12-11 00:05:04 +00:00
Sebastian Dröge 749423bb7f core: Add/fix various annotations
And fix memory leaks/null pointer dereferences in GstUri in error cases.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3194>
2022-10-18 13:51:16 +03:00
Philipp Zabel 3b900e1fa4 buffer: drop parent meta in deep copy/foreach_metadata
The purpose of a deep buffer copy is to be able to release the source
buffer and all its dependencies. Attaching the parent buffer meta to
the newly created deep copy needlessly keeps holding a reference to the
parent buffer.

The issue this solves is the fact you need to allocate more
buffers, as you have free buffers being held for no reason. In the good
cases it will use more memory, in the bad case it will stall your
pipeline (since codecs often need a minimum number of buffers to
actually work).

Fixes #283

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2928>
2022-09-28 12:34:44 -06:00
Xavier Claessens 8bf778bb1f Add GstBufferMapInfo to be used with g_auto()
We need a separate typedef for this feature because GstMapInfo itself
can be initialized by gst_memory_map() in which case info.memory should
not be unreffed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2412>
2022-06-20 16:17:50 +00:00
Thibault Saunier 6c364d9626 Move files from gstreamer into the "subprojects/gstreamer/" subdir 2021-09-24 16:13:07 -03:00
Renamed from gst/gstbuffer.c (Browse further)