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
This commit is contained in:
Sebastian Dröge 2016-12-15 12:48:55 +02:00
parent e7ede5a487
commit c77f661f6d
4 changed files with 31 additions and 0 deletions

View 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

View 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

View 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,

View 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