Remove bus watch when tearing down pipeline

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Remove bus watch when tearing down pipeline

Guillermo Rodriguez Garcia-2
Hello,

I have a GStreamer application that can create and tear down multiple pipelines.
For each pipeline that is created I am attaching a bus watch as follows:

GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
gst_bus_add_watch(bus, bus_error_handler, NULL);
gst_object_unref(bus);

When I tear down the pipeline (by setting its state to NULL, and then
calling gst_object_unref(pipeline), do I need to explicitly remove the
bus watch to prevent resource leaks?

I understood that this was not necessary and that the bus watch should
be destroyed automatically, together with the bus. But I am seeing
that the bus watch is explicitly removed in some samples:

https://gstreamer.freedesktop.org/documentation/application-development/basics/bus.html

Can someone clarify?

Thank you,

Guillermo Rodriguez Garcia
[hidden email]
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Remove bus watch when tearing down pipeline

Sebastian Dröge-3
On Wed, 2020-09-02 at 10:09 +0200, Guillermo Rodriguez Garcia wrote:
>
> When I tear down the pipeline (by setting its state to NULL, and then
> calling gst_object_unref(pipeline), do I need to explicitly remove
> the bus watch to prevent resource leaks?
>
> I understood that this was not necessary and that the bus watch
> should be destroyed automatically, together with the bus.

If you don't explicitly destroy it then it will still be attached to
the GMainContext until that is freed (which will never happen if you
use the global default one).

--
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Remove bus watch when tearing down pipeline

Guillermo Rodriguez Garcia-2
Hi Sebastian,

El mié., 2 sept. 2020 a las 11:05, Sebastian Dröge
(<[hidden email]>) escribió:

>
> On Wed, 2020-09-02 at 10:09 +0200, Guillermo Rodriguez Garcia wrote:
> >
> > When I tear down the pipeline (by setting its state to NULL, and then
> > calling gst_object_unref(pipeline), do I need to explicitly remove
> > the bus watch to prevent resource leaks?
> >
> > I understood that this was not necessary and that the bus watch
> > should be destroyed automatically, together with the bus.
>
> If you don't explicitly destroy it then it will still be attached to
> the GMainContext until that is freed (which will never happen if you
> use the global default one).

Thank you very much.
I was confused by this:
https://lists.freedesktop.org/archives/gstreamer-devel/2015-August/054038.html

Thanks,

Guillermo Rodriguez Garcia
[hidden email]
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel