gst_bus_add_watch()和g_signal_connect()之间的区别 [英] Difference between gst_bus_add_watch() and g_signal_connect()

查看:449
本文介绍了gst_bus_add_watch()和g_signal_connect()之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读GStreamer应用程序开发人员手册,该手册讨论了消息处理/事件处理上下文中的管道总线,他们讨论了2个函数:gst_bus_add_watch()和g_signal_connect().看来这两个功能是可以互换的.应用手册说:

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:

请注意,如果您使用默认的GLib mainloop集成,则可以附加手表,而不必附加手表, 连接到总线上的消息"信号.

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.

在第27页中.这两个功能有什么区别,它们在什么情况下有用?谁使用我们在这些函数中注册的回调?元素本身是否调用回调?

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?

推荐答案

如果您使用的是gst_bus_add_watch(),那么您将提供一个回调,当消息可用时将调用该回调.

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

如果您调用gst_bus_add_signal_watch(),那么它将注册一个默认回调,该回调会将GSource注册到主循环.这样可以使用信号.

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.

在功能上是等效的,但是如果您是编写基于glib/gtk的应用程序,到处都使用信号可能会提高代码的一致性.

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.

这篇关于gst_bus_add_watch()和g_signal_connect()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆