Using "convert-sample" from playbin

Chris Tapp opensource at keylevel.com
Mon Aug 4 00:52:04 PDT 2014


On 4 Aug 2014, at 07:15, Sebastian Dröge <sebastian at centricular.com> wrote:

> On So, 2014-08-03 at 20:12 +0100, Chris Tapp wrote:
>> On 3 Aug 2014, at 08:37, Sebastian Dröge <sebastian at centricular.com> wrote:
>> 
>>> On So, 2014-08-03 at 01:45 +0100, Chris Tapp wrote:
>>>> I want to be able to grab a converted copy of the most recent frame from a video pipeline.
>>>> 
>>>> The pipeline is created using gst_parse_launch() and contains a "playbin" element.
>>> 
>>> You can also just use pipeline = gst_element_factory_make("playbin", NULL);
>>> 
>>>> I then use the following to grab and process the converted frames:
>>>> 
>>>> g_signal_emit_by_name( pipeline, "convert-sample", target_caps, &frame );
>>>> 
>>>> // Process frame...
>>>> 
>>>> gst_sample_unref( frame );
>>>> 
>>>> However, this causes a memory leak. What am I doing wrong?
>>> 
>>> Impossible to say without more code. Can you provide a testcase that
>>> reproduces it?
>> 
>> I've actually reduced the code to just a little bit more than above and still see the problem:
>> 
>> GstCaps * caps;
>> 
>> caps = gst_caps_new_simple( ... );
>> 
>> g_signal_emit_by_name( pipeline, "convert-sample", target_caps, &frame );
>> 
>> // Process frame...
>> 
>> gst_sample_unref( frame );
>> 
>> gst_caps_unref( caps );
>> 
>> After a bit of digging I noticed that GST_OBJECT_REFCOUNT_VALUE( frame ) reports a ref count of 2, but I would have expected a value of 1.
>> 
>> Adding a second gst_sample_unref( frame ) call fixes the problem.
> 
> That's not a fix though :)

True ;-)

> What are you doing between g_signal_emit_by_name() and
> gst_sample_unref()? Are you leaking a reference of anything from the
> sample there?

No, nothing at all. The code is literally as shown above (i.e. all of my processing removed) with the ref count being '2' as soon as g_signal_emit_by_name() returns.

> -- 
> Sebastian Dröge, Centricular Ltd - http://www.centricular.com
> Expertise, Straight from the Source
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

Chris Tapp

opensource at keylevel.com
www.keylevel.com





More information about the gstreamer-devel mailing list