gst_buffer_unref fails on appsink callback for local variables

Thiago Santos thiagoss at osg.samsung.com
Mon Dec 1 16:25:08 PST 2014


On 12/01/2014 11:29 AM, ign bra wrote:
> Hello folks, I am playing with appsink and try to get buffer from appsink.
> This part OK.
> Problem is when I do cleaning. GstBuffer fails to unref after pull:
>
> static GstFlowReturn gstre_pull_sample_cb(GstElement* gstappsink,
>                                            gpointer data){
>      GstSample* sample;
>      GstBuffer* buffer;
>      GstCaps* caps;
>      g_signal_emit_by_name (gstappsink, "pull-sample", &sample);
>      if (sample) {
>        buffer = gst_sample_get_buffer(sample);
>        caps = gst_sample_get_caps(sample);
>        gst_buffer_unref(buffer);
>        g_print ("*");
>        gst_sample_unref(sample);
>      }
>
>
>      return GST_FLOW_OK;
> }
>
> I think I am missing something trivial about memory managment, because unref
> call simply fails for buffer push:
>
> ** (GstReencoderTest:1624): CRITICAL **: gst_video_frame_map_id: assertion
> 'GST_IS_BUFFER (buffer)' failed
>
> (GstReencoderTest:1624): GStreamer-CRITICAL **: gst_pad_push: assertion
> 'GST_IS_BUFFER (buffer)' failed
>
> (GstReencoderTest:1624): GStreamer-CRITICAL **: gst_mini_object_unref:
> assertion 'mini_object->refcount > 0' failed
>
> How to properly release buffer in callback, I seem to fail and overunref it,
> I don't know how.
https://developer.gnome.org/gstreamer/stable/gstreamer-GstSample.html#gst-sample-get-buffer

The return for the gst_sample_get_buffer is marked as 'transfer-none', 
which means that you don't own the ref you get from it so you don't need 
to unref. If you would like to keep the buffer around for some future 
processing you need to _ref it to make sure your pointer will still be 
valid when you need it.

>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/gst-buffer-unref-fails-on-appsink-callback-for-local-variables-tp4669760.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


-- 
Thiago Sousa Santos
Senior Multimedia Engineer, Open Source Group
Samsung Research America - Silicon Valley



More information about the gstreamer-devel mailing list