buffer: Add GstParentBufferMeta to copied buffer sharing memory
When copying a buffer (e.g. with gst_buffer_make_writable) the result
is often two buffer instances backed by the same GstMemory instance.
If the original buffer is pooled, unreffed and returned to the
pool before the copy is freed, the pool will detect that the backing
memory isn't writable (becuase it's still in use by the copy). The
pool thus rejects the original buffer and instead allocates a new one.
This is mostly fine, typically just a sligt hit to performance. The
big problem for us are elements that incorrectly (against GStreamer
design docs) assume that the buffers in a buffer pool never change
once activated. One such element is NXP's vpudec that after the pool
is activated dequeues all buffers and does its own bookkeeping that
relies on the pool never returning buffers that weren't there from
the very start. This assumption breaks if a buffer is returned to
the pool but its backing memory is still in use by a copy.
While fixing the erroneous elements would be the right thing it's
more feasible to ensure that an original buffer always outlives
any copies sharing its memory. In the case of vpudec the underlying
VPU support libraries don't support changing buffers without tearing
everything down and bringing it back up.
1 file changed