Bus.poll

Poll the bus for messages. Will block while waiting for messages to come. You can specify a maximum time to poll with the timeout parameter. If timeout is negative, this function will block indefinitely.

All messages not in events will be popped off the bus and will be ignored. It is not possible to use message enums beyond GST_MESSAGE_EXTENDED in the events mask

Because poll is implemented using the "message" signal enabled by Bus.addSignalWatch, calling Bus.poll will cause the "message" signal to be emitted for every message that poll sees. Thus a "message" signal handler will see the same messages that this function sees -- neither will steal messages from the other.

This function will run a main loop from the default main context when polling.

You should never use this function, since it is pure evil. This is especially true for GUI applications based on Gtk+ or Qt, but also for any other non-trivial application that uses the GLib main loop. As this function runs a GLib main loop, any callback attached to the default GLib main context may be invoked. This could be timeouts, GUI events, I/O events etc.; even if Bus.poll is called with a 0 timeout. Any of these callbacks may do things you do not expect, e.g. destroy the main application window or some other resource; change other application state; display a dialog and run another main loop until the user clicks it away. In short, using this function may add a lot of complexity to your code through unexpected re-entrancy and unexpected changes to your application's state.

For 0 timeouts use Bus.popFiltered instead of this function; for other short timeouts use Bus.timedPopFiltered; everything else is better handled by setting up an asynchronous bus watch and doing things from there.

Parameters

events GstMessageType

a mask of GstMessageType, representing the set of message types to poll for (note special handling of extended message types below)

timeout GstClockTime

the poll timeout, as a GstClockTime, or GST_CLOCK_TIME_NONE to poll indefinitely.

Return Value

Type: Message

the message that was received, or NULL if the poll timed out. The message is taken from the bus and needs to be unreffed with Message.unref after usage.