Poll

A GstPoll keeps track of file descriptors much like fd_set (used with select()) or a struct pollfd array (used with poll()). Once created with gst_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 gst_poll_set_controllable()).

New file descriptors are added to the set using gst_poll_add_fd(), and removed using gst_poll_remove_fd(). Controlling which file descriptors should be waited for to become readable and/or writable are done using gst_poll_fd_ctl_read() and gst_poll_fd_ctl_write().

Use gst_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 gst_poll_restart() and gst_poll_set_flushing().

Once the file descriptor set has been waited for, one can use gst_poll_fd_has_closed() to see if the file descriptor has been closed, gst_poll_fd_has_error() to see if it has generated an error, gst_poll_fd_can_read() to see if it is possible to read from the file descriptor, and gst_poll_fd_can_write() to see if it is possible to write to it.

Constructors

this
this(GstPoll* gstPoll)

Sets our main struct and passes it to the parent class

this
this(int controllable)

Create a new file descriptor set. If controllable, it is possible to restart or flush a call to gst_poll_wait() with gst_poll_restart() and gst_poll_set_flushing() respectively. Free-function: gst_poll_free

this
this()

Create a new poll object that can be used for scheduling cancellable timeouts. A timeout is performed with gst_poll_wait(). Multiple timeouts can be performed from different threads. Free-function: gst_poll_free

Members

Functions

addFd
int addFd(GstPollFD* fd)

Add a file descriptor to the file descriptor set.

fdCanRead
int fdCanRead(GstPollFD* fd)

Check if fd in set has data to be read.

fdCanWrite
int fdCanWrite(GstPollFD* fd)

Check if fd in set can be used for writing.

fdCtlRead
int fdCtlRead(GstPollFD* fd, int active)

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

fdCtlWrite
int fdCtlWrite(GstPollFD* fd, int active)

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

fdHasClosed
int fdHasClosed(GstPollFD* fd)

Check if fd in set has closed the connection.

fdHasError
int fdHasError(GstPollFD* fd)

Check if fd in set has an error.

fdIgnored
void fdIgnored(GstPollFD* fd)

Mark fd as ignored so that the next call to gst_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 gst_poll_wait(). The reason why this is needed is because the underlying implementation might not allow querying the fd more than once between calls to one of the re-enabling operations.

free
void free()

Free a file descriptor set.

getPollStruct
GstPoll* getPollStruct()

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
int readControl()

Read a byte from the control socket of the controllable set. This function is mostly useful for timer GstPoll objects created with gst_poll_new_timer().

removeFd
int removeFd(GstPollFD* fd)

Remove a file descriptor from the file descriptor set.

restart
void restart()

Restart any gst_poll_wait() that is in progress. This function is typically used after adding or removing descriptors to set. If set is not controllable, then this call will have no effect.

setControllable
int setControllable(int controllable)

When controllable is TRUE, this function ensures that future calls to gst_poll_wait() will be affected by gst_poll_restart() and gst_poll_set_flushing().

setFlushing
void setFlushing(int flushing)

When flushing is TRUE, this function ensures that current and future calls to gst_poll_wait() will return -1, with errno set to EBUSY. Unsetting the flushing state will restore normal operation of set.

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. For GstPoll objects created with gst_poll_new(), this function can only be called from a single thread at a time. If called from multiple threads, -1 will be returned with errno set to EPERM. This is not true for timer GstPoll objects created with gst_poll_new_timer(), where it is allowed to have multiple threads waiting simultaneously.

writeControl
int writeControl()

Write a byte to the control socket of the controllable set. This function is mostly useful for timer GstPoll objects created with gst_poll_new_timer(). It will make any current and future gst_poll_wait() function return with 1, meaning the control socket is set. After an equal amount of calls to gst_poll_read_control() have been performed, calls to gst_poll_wait() will block again until their timeout expired.

Static functions

fdInit
void fdInit(GstPollFD* fd)

Initializes fd. Alternatively you can initialize it with GST_POLL_FD_INIT.

Variables

gstPoll
GstPoll* gstPoll;

the main Gtk struct

Meta