Poll

A gstreamer.Poll keeps track of file descriptors much like fd_set (used with select()) or a struct pollfd array (used with poll()). Once created with Poll.new, the set can be used to wait for file descriptors to be readable and/or writable. It is possible to make this wait be controlled by specifying TRUE for the controllable flag when creating the set (or later calling Poll.setControllable).

New file descriptors are added to the set using Poll.addFd, and removed using Poll.removeFd. Controlling which file descriptors should be waited for to become readable and/or writable are done using Poll.fdCtlRead and Poll.fdCtlWrite.

Use Poll.wait to wait for the file descriptors to actually become readable and/or writable, or to timeout if no file descriptor is available in time. The wait can be controlled by calling Poll.restart and Poll.setFlushing.

Once the file descriptor set has been waited for, one can use Poll.fdHasClosed to see if the file descriptor has been closed, Poll.fdHasError to see if it has generated an error, Poll.fdCanRead to see if it is possible to read from the file descriptor, and Poll.fdCanWrite to see if it is possible to write to it.

Constructors

this
this(GstPoll* gstPoll, bool ownedRef = false)

Sets our main struct and passes it to the parent class.

this
this(bool controllable)

Create a new file descriptor set. If controllable, it is possible to restart or flush a call to Poll.wait with Poll.restart and Poll.setFlushing respectively.

this
this()

Create a new poll object that can be used for scheduling cancellable timeouts.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

addFd
bool addFd(PollFD fd)

Add a file descriptor to the file descriptor set.

fdCanRead
bool fdCanRead(PollFD fd)

Check if fd in set has data to be read.

fdCanWrite
bool fdCanWrite(PollFD fd)

Check if fd in set can be used for writing.

fdCtlRead
bool fdCtlRead(PollFD fd, bool active)

Control whether the descriptor fd in set will be monitored for readability.

fdCtlWrite
bool fdCtlWrite(PollFD fd, bool active)

Control whether the descriptor fd in set will be monitored for writability.

fdHasClosed
bool fdHasClosed(PollFD fd)

Check if fd in set has closed the connection.

fdHasError
bool fdHasError(PollFD fd)

Check if fd in set has an error.

fdIgnored
void fdIgnored(PollFD fd)

Mark fd as ignored so that the next call to Poll.wait will yield the same result for fd as last time. This function must be called if no operation (read/write/recv/send/etc.) will be performed on fd before the next call to Poll.wait.

free
void free()

Free a file descriptor set.

getPollStruct
GstPoll* getPollStruct(bool transferOwnership = false)

Get the main Gtk struct

getReadGpollfd
void getReadGpollfd(GPollFD* fd)

Get a GPollFD for the reading part of the control socket. This is useful when integrating with a GSource and GMainLoop.

getStruct
void* getStruct()

the main Gtk struct as a void*

readControl
bool readControl()

Read a byte from the control socket of the controllable set.

removeFd
bool removeFd(PollFD fd)

Remove a file descriptor from the file descriptor set.

restart
void restart()

Restart any Poll.wait that is in progress. This function is typically used after adding or removing descriptors to set.

setControllable
bool setControllable(bool controllable)

When controllable is TRUE, this function ensures that future calls to Poll.wait will be affected by Poll.restart and Poll.setFlushing.

setFlushing
void setFlushing(bool flushing)

When flushing is TRUE, this function ensures that current and future calls to Poll.wait will return -1, with errno set to EBUSY.

wait
int wait(GstClockTime timeout)

Wait for activity on the file descriptors in set. This function waits up to the specified timeout. A timeout of GST_CLOCK_TIME_NONE waits forever.

writeControl
bool writeControl()

Write a byte to the control socket of the controllable set. This function is mostly useful for timer gstreamer.Poll objects created with Poll.newTimer.

Variables

gstPoll
GstPoll* gstPoll;

the main Gtk struct

Meta