diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2016-12-15 12:48:55 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-05-09 15:01:46 +0200 |
commit | c77f661f6d8d9f30437e1142219d50597a1d55b6 (patch) | |
tree | 86652143d9e396ab27f92deee6a506b5a76476e1 | |
parent | e7ede5a487d8c1571a4387a5f8eeb4d5e73a9553 (diff) |
bus: Add function to get the file descriptor of the bus
This is useful for integration with other event loops that work by
polling file descriptors. G_IO_IN will always be set whenever a message
is available currently.
https://bugzilla.gnome.org/show_bug.cgi?id=776126
-rw-r--r-- | docs/gst/gstreamer-sections.txt | 1 | ||||
-rw-r--r-- | gst/gstbus.c | 25 | ||||
-rw-r--r-- | gst/gstbus.h | 4 | ||||
-rw-r--r-- | win32/common/libgstreamer.def | 1 |
4 files changed, 31 insertions, 0 deletions
diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 18f106fb7..582157ab2 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -134,6 +134,7 @@ gst_bus_timed_pop_filtered gst_bus_set_flushing gst_bus_set_sync_handler gst_bus_sync_signal_handler +gst_bus_get_pollfd gst_bus_create_watch gst_bus_add_watch_full gst_bus_add_watch diff --git a/gst/gstbus.c b/gst/gstbus.c index 6a7820cbb..f4039db1c 100644 --- a/gst/gstbus.c +++ b/gst/gstbus.c @@ -761,6 +761,31 @@ no_replace: } } +/** + * gst_bus_get_pollfd: + * @bus: A #GstBus + * @fd: A GPollFD to fill + * + * Gets the file descriptor from the bus which can be used to get notified about + * messages being available with functions like g_poll(), and allows integration + * into other event loops based on file descriptors. + * Whenever a message is available, the %POLLIN / %G_IO_IN event is set. + * + * Warning: NEVER read or write anything to the returned fd but only use it + * for getting notifications via g_poll() or similar and then use the normal + * GstBus API, e.g. gst_bus_pop(). + * + * Since: 1.14 + */ +void +gst_bus_get_pollfd (GstBus * bus, GPollFD * fd) +{ + g_return_if_fail (GST_IS_BUS (bus)); + g_return_if_fail (bus->priv->poll != NULL); + + *fd = bus->priv->pollfd; +} + /* GSource for the bus */ typedef struct diff --git a/gst/gstbus.h b/gst/gstbus.h index ed49b2e48..fbacf7b2d 100644 --- a/gst/gstbus.h +++ b/gst/gstbus.h @@ -149,6 +149,10 @@ void gst_bus_set_flushing (GstBus * bus, gboolean /* synchronous dispatching */ void gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func, gpointer user_data, GDestroyNotify notify); + +/* asynchronous message notifications */ +void gst_bus_get_pollfd (GstBus * bus, GPollFD *fd); + /* GSource based dispatching */ GSource * gst_bus_create_watch (GstBus * bus); guint gst_bus_add_watch_full (GstBus * bus, diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index bc4bd5506..389f52859 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -209,6 +209,7 @@ EXPORTS gst_bus_disable_sync_message_emission gst_bus_enable_sync_message_emission gst_bus_flags_get_type + gst_bus_get_pollfd gst_bus_get_type gst_bus_have_pending gst_bus_new |