bus: Add function to get the file descriptor of the bus
authorSebastian Dröge <sebastian@centricular.com>
Thu, 15 Dec 2016 10:48:55 +0000 (12:48 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 9 May 2017 13:01:46 +0000 (15:01 +0200)
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

docs/gst/gstreamer-sections.txt
gst/gstbus.c
gst/gstbus.h
win32/common/libgstreamer.def

index 18f106f..582157a 100644 (file)
@@ -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
index 6a7820c..f4039db 100644 (file)
@@ -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
index ed49b2e..fbacf7b 100644 (file)
@@ -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,
index bc4bd55..389f528 100644 (file)
@@ -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