diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 18f106fb73..582157ab28 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 6a7820cbb1..f4039db1cf 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 ed49b2e482..fbacf7b2de 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 bc4bd55067..389f528591 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