Mapping appsink buffer as READWRITE always copies data

Sebastian Dröge sebastian at centricular.com
Sat Sep 19 07:06:21 UTC 2020


On Fri, 2020-09-18 at 19:22 -0600, Michael Gruner wrote:
> Here’s my log from the minimal example:
> Sample refcount: 2
> Buffer 1 refcount: 1
> Buffer 1 is writable: 0
> Buffer 2 refcount: 1. <———— Made the buffer writable
> Buffer 2 is writable: 1
> Memcpy below

The buffer is not writable because its parent (the sample) is not
writable (has a reference count > 1). This happens because appsink
caches the sample to not have to re-create it for every buffer.

This changed relatively recently, both the caching of the sample inside
appsink and the considering of the parent reference count for
determining writability. The latter is needed to fix memory corruption
that can otherwise happen.


Best to create an issue in GitLab about this so it can be discussed. It
seems rather unfortunate and probably means that something should be
fixed there.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com




More information about the gstreamer-devel mailing list