Difference between gst_bus_add_watch() and g_signal_connect()

放肆的年华 提交于 2019-12-08 00:00:03

问题


I'm reading the GStreamer application developer manual, which talks about the pipeline bus in the context of message handling / event handling, they talk about 2 functions: gst_bus_add_watch() and g_signal_connect(). It appears that these 2 functions are interchangeable. The application manual says:

Note that if you’re using the default GLib mainloop integration, you can, instead of attaching a watch, connect to the “message” signal on the bus.

In page 27. What's the difference between these 2 functions, and in what contexts are they useful? Who uses the callbacks that we register in these functions? Does the element itself call the callbacks?


回答1:


If you are using gst_bus_add_watch() then you provide a callback that will be called when a message is available.

If you call gst_bus_add_signal_watch() then that registers a default callback that will register a GSource to the main-loop. This enables the use of signals.

It is functionality wise equivalent, but if you are e.g. writing a glib/gtk based app, using signal everywhere might give your code more consistency.



来源:https://stackoverflow.com/questions/37220063/difference-between-gst-bus-add-watch-and-g-signal-connect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!