[gst-devel] Why do we call gst_object_unref() ?

Tony Houghton h at realh.co.uk
Sun Jan 2 14:34:32 CET 2011


On 02/01/11 06:43, gst_call_me_newbie() wrote:
> I checked the meaning of the function gst_object_unref() and got what it
> does but I could not get why do we call it while the program is in
> execution.
>
> for e.g this is a code snippet from the application developer manual
> provided at the gstreamer's site.
>
> [some code here.....]
> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
> gst_bus_add_watch (bus, my_bus_callback, loop);
> gst_object_unref (bus);
> [some other code here.....]
>
> so why would someone want to unref the bus when we still need it in our
> program. If I unref it and if somehow that would have been the last
> reference to the object than object would surely be destroyed.
> so why should I call it. Please enlighten me.

Presumably the get functions such as gst_pipeline_get_bus()
automatically add a reference to each object they return, so when the
object is no longer needed in the context that requested it you have to
unref it.




More information about the gstreamer-devel mailing list