[gst-devel] Question on gst_bus_add/remove_signal_watch functions

Tim Müller t.i.m at zen.co.uk
Thu Dec 6 21:12:44 CET 2007


On Thu, 2007-12-06 at 13:44 -0500, José Alburquerque wrote:

> One such question is related 
> to the gst_bus_add/remove_signal_watch[_full] functions (which I'm 
> presently working on right now).  As I understand the docs, 
> gst_add_signal_watch[_full] can be called several times, but 
> remove_signal_watch must be called the same number of times to remove 
> the watches.
> 
> My question is:  does the message signal get transmitted as many times 
> as gst_bus_add_signal_watch() has been called or just once regardless?

The signal gets emitted exactly once per message, regardless of how
often gst_bus_add_signal_watch() has been called.


> If so, why allow several calls to gst_bus_add_signal_watch().

To make it easier for independent pieces of code to watch for the same
signal (they don't need to worry about what's done elsewhere in the
application or in other libraries, but only need to call _add/_remove as
required for their own purposes).


> Also, am I correct in assuming that the GstBus is not destroyed unless 
> gst_bus_remove_signal_watch() is called the same number of times that 
> gst_bus_add_signal_watch[_full]() has been called?

Yes: gst_bus_add_signal_watch() calls gst_bus_add_watch_full() which
calls gst_bus_create_watch() which takes a reference to the bus, and
that reference is not dropped until the source is removed, which only
happens when _remove_signal_watch() has been called as many times as
_add_signal_watch() has been called before.

 Cheers
  -Tim






More information about the gstreamer-devel mailing list