<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello all<div class=""><br class=""></div><div class="">It seems like I can never map a buffer as READWRITE that I just pulled from an appsink without the map copying the underlying data. I have a bare minimal example here:</div><div class=""><br class=""></div><div class=""><a href="https://pastebin.ubuntu.com/p/27b6K4VX6c/" class="">https://pastebin.ubuntu.com/p/27b6K4VX6c/</a></div><div class=""><br class=""></div><div class="">You may run it as:</div><div class=""><i class="">cc -o gst gst.c `pkg-config --cflags --libs gstreamer-1.0 gstreamer-app-1.0`<br class="">GST_DEBUG=2,GST_PERFORMANCE:9,GST_BUFFER:9,GST_MEMORY:9,GST_LOCKING:9 ./gst</i></div><div class=""><br class=""></div><div class="">The pipeline is simply:</div><div class=""><i class="">"videotestsrc ! appsink name=sink enable-last-sample=false max-buffers=1 drop=false”</i></div><div class=""><br class=""></div><div class="">The process is also simple:</div><div class="">1. Pull the sample</div><div class="">2. Get the buffer from the sample</div><div class="">3. Make it writable</div><div class="">4. Map it as READWRITE <————— Copy occurs</div><div class="">5. Unmap</div><div class="">6. Unref</div><div class=""><br class=""></div><div class="">Here’s my log from the minimal example:</div><div class=""><div class=""><i class="">Sample refcount: 2</i></div><div class=""><i class="">Buffer 1 refcount: 1</i></div><div class=""><i class="">Buffer 1 is writable: 0</i></div><div class=""><i class="">Buffer 2 refcount: 1. <———— Made the buffer writable</i></div><div class=""><i class="">Buffer 2 is writable: 1</i></div><div class=""><i class="">Memcpy below</i></div><div class=""><i class="">…</i></div><div class=""><i class="">0:00:00.059691000 33882 0x7f9c55e0e000 TRACE GST_LOCKING gstminiobject.c:221:gboolean gst_mini_object_lock(GstMiniObject *, GstLockFlags): lock 0x7f9c58000000: state 00020000, access_mode 3</i></div><div class=""><i class="">0:00:00.059706000 33882 0x7f9c55e0e000 DEBUG GST_LOCKING gstminiobject.c:256:gboolean gst_mini_object_lock(GstMiniObject *, GstLockFlags): lock failed 0x7f9c58000000: state 00020000, access_mode 3</i></div><div class=""><i class="">...</i></div><div class=""><i class="">0:00:00.059753000 33882 0x7f9c55e0e000 DEBUG GST_PERFORMANCE gstallocator.c:461:GstMemorySystem *_sysmem_copy(GstMemorySystem *, gssize, gsize): memcpy 115200 memory 0x7f9c58000000 -> 0x7f9c5804b000</i></div><div class=""><i class="">...</i></div><div class=""><i class="">Memcpy above</i></div></div><div class=""><br class=""></div><div class="">I’ve tried changing the source to verify it’s not a videotestsrc thing, forcing processing in the middle, unreffing the sample earlier. Nothing seems to make a difference.</div><div class=""><br class=""></div><div class="">I appreciate some light on this, or if it’s an actual bug, I’d be happy to help with the fix.</div><div class=""><br class=""></div><div class="">Thanks!</div><div class="">Michael</div></body></html>