Class (GI Struct)

Gst-1.0GstPollAbstract

A Gst.Poll 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(), gst_poll_fd_ctl_write() and gst_poll_fd_ctl_pri().

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.

Index

Constructors

Properties

$gtype: GType<Poll>

Methods

  • Add a file descriptor to the file descriptor set.

    Parameters

    Returns boolean

    true if the file descriptor was successfully added to the set.

  • Check if fd in set can be used for writing.

    Parameters

    Returns boolean

    true if the descriptor can be used for writing.

  • Control whether the descriptor fd in set will be monitored for exceptional conditions (POLLPRI).

    Not implemented on Windows (will just return false there).

    Parameters

    • fd: Gst.PollFD

      a file descriptor.

    • active: boolean

      a new status.

    Returns boolean

    true if the descriptor was successfully updated.

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

    Parameters

    • fd: Gst.PollFD

      a file descriptor.

    • active: boolean

      a new status.

    Returns boolean

    true if the descriptor was successfully updated.

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

    Parameters

    • fd: Gst.PollFD

      a file descriptor.

    • active: boolean

      a new status.

    Returns boolean

    true if the descriptor was successfully updated.

  • Check if fd in set has an exceptional condition (POLLPRI).

    Not implemented on Windows (will just return false there).

    Parameters

    Returns boolean

    true if the descriptor has an exceptional condition.

  • 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.

    Parameters

    Returns void

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

    This function only works for timer Gst.Poll objects created with gst_poll_new_timer().

    Returns boolean

    true on success. false when when there was no byte to read or reading the byte failed. If there was no byte to read, and only then, errno will contain EWOULDBLOCK or EAGAIN. For all other values of errno this always signals a critical error.

  • Remove a file descriptor from the file descriptor set.

    Parameters

    Returns boolean

    true if the file descriptor was successfully removed from the set.

  • 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.

    This function only works for non-timer Gst.Poll objects created with gst_poll_new().

    Returns void

  • 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().

    This function only works for non-timer Gst.Poll objects created with gst_poll_new().

    Parameters

    • controllable: boolean

      new controllable state.

    Returns boolean

    true if the controllability of set could be updated.

  • 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.

    This function only works for non-timer Gst.Poll objects created with gst_poll_new().

    Parameters

    • flushing: boolean

      new flushing state.

    Returns void

  • 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 Gst.Poll 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 Gst.Poll objects created with gst_poll_new_timer(), where it is allowed to have multiple threads waiting simultaneously.

    Parameters

    • timeout: number

      a timeout in nanoseconds.

    Returns number

    The number of Gst.PollFD in set that have activity or 0 when no activity was detected after timeout. If an error occurs, -1 is returned and errno is set.

  • Write a byte to the control socket of the controllable set. This function is mostly useful for timer Gst.Poll 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.

    This function only works for timer Gst.Poll objects created with gst_poll_new_timer().

    Returns boolean

    true on success. false when when the byte could not be written. errno contains the detailed error code but will never be EAGAIN, EINTR or EWOULDBLOCK. false always signals a critical error.