libgstapp ownership
Chris Tapp
opensource at keylevel.com
Mon Oct 20 13:04:41 PDT 2014
Hi Tim,
On 20 Oct 2014, at 20:52, Tim Müller <tim at centricular.com> wrote:
> On Mon, 2014-10-20 at 20:19 +0100, Chris Tapp wrote:
>
> Hi Chris,
>
>> The documentation for gst_app_src_push_buffer() says "This function
>> takes ownership of the buffer" does that mean it adds a ref count to
>> the buffer, or does it just mean that a ref-counted object passed in
>> does not have to be unref'ed?
>
> It means when you pass in a ref-counted or allocated object, you must
> not use it afterwards and do not need to unref/free it. You can always
> add another ref of course if you want to hang on to it and then unref
> that again later.
That makes sense. Thanks for the clarification.
> For example, is the following valid:
>>
>> GstBuffer * buffer = gst_sample_get_buffer( aSample ); // Buffer is valid as long as aSample is valid - take a reference if needed longer
>>
>> gst_app_src_push_buffer( myAppSrc, buffer ); // Does push_buffer take a reference?
>
> This is not valid, because gst_sample_get_buffer() does not give you a
> reference to the buffer, but push_buffer() gives away a reference, so
> now you basically gave away the sample's reference, and things will go
> downhill quickly from here.
>
>> or should it be:
>>
>> gst_app_src_push_buffer( myAppSrc, gst_sample_ref( buffer ) ); // Take a reference before passing in.
>
> This is correct in this particular context.
--
Chris Tapp
opensource at keylevel.com
www.keylevel.com
----
You can tell you're getting older when your car insurance gets real cheap!
More information about the gstreamer-devel
mailing list