gi-gst-1.0.25: GStreamer bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gst.Structs.Poll

Description

A 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 pollSetControllable).

New file descriptors are added to the set using pollAddFd, and removed using pollRemoveFd. Controlling which file descriptors should be waited for to become readable and/or writable are done using pollFdCtlRead, pollFdCtlWrite and pollFdCtlPri.

Use pollWait 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 pollRestart and pollSetFlushing.

Once the file descriptor set has been waited for, one can use pollFdHasClosed to see if the file descriptor has been closed, pollFdHasError to see if it has generated an error, pollFdCanRead to see if it is possible to read from the file descriptor, and pollFdCanWrite to see if it is possible to write to it.

Synopsis

Exported types

newtype Poll Source #

Memory-managed wrapper type.

Constructors

Poll (ManagedPtr Poll) 

Instances

Instances details
Eq Poll Source # 
Instance details

Defined in GI.Gst.Structs.Poll

Methods

(==) :: Poll -> Poll -> Bool #

(/=) :: Poll -> Poll -> Bool #

BoxedPtr Poll Source # 
Instance details

Defined in GI.Gst.Structs.Poll

Methods

boxedPtrCopy :: Poll -> IO Poll #

boxedPtrFree :: Poll -> IO () #

ManagedPtrNewtype Poll Source # 
Instance details

Defined in GI.Gst.Structs.Poll

Methods

Click to display all available methods, including inherited ones

Expand

Methods

addFd, fdCanRead, fdCanWrite, fdCtlPri, fdCtlRead, fdCtlWrite, fdHasClosed, fdHasError, fdHasPri, fdIgnored, readControl, removeFd, restart, wait, writeControl.

Getters

getReadGpollfd.

Setters

setControllable, setFlushing.

addFd

pollAddFd Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> m Bool

Returns: True if the file descriptor was successfully added to the set.

Add a file descriptor to the file descriptor set.

fdCanRead

pollFdCanRead Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> m Bool

Returns: True if the descriptor has data to be read.

Check if fd in set has data to be read.

fdCanWrite

pollFdCanWrite Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> m Bool

Returns: True if the descriptor can be used for writing.

Check if fd in set can be used for writing.

fdCtlPri

pollFdCtlPri Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> Bool

active: a new status.

-> m Bool

Returns: True if the descriptor was successfully updated.

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

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

Since: 1.16

fdCtlRead

pollFdCtlRead Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> Bool

active: a new status.

-> m Bool

Returns: True if the descriptor was successfully updated.

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

fdCtlWrite

pollFdCtlWrite Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> Bool

active: a new status.

-> m Bool

Returns: True if the descriptor was successfully updated.

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

fdHasClosed

pollFdHasClosed Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> m Bool

Returns: True if the connection was closed.

Check if fd in set has closed the connection.

fdHasError

pollFdHasError Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> m Bool

Returns: True if the descriptor has an error.

Check if fd in set has an error.

fdHasPri

pollFdHasPri Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> m Bool

Returns: True if the descriptor has an exceptional condition.

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

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

Since: 1.16

fdIgnored

pollFdIgnored Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> m () 

Mark fd as ignored so that the next call to pollWait 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 pollWait.

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.

getReadGpollfd

pollGetReadGpollfd Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a Poll

-> PollFD

fd: a PollFD

-> m () 

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

readControl

pollReadControl Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a Poll.

-> m Bool

Returns: 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.

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

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

removeFd

pollRemoveFd Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a file descriptor set.

-> PollFD

fd: a file descriptor.

-> m Bool

Returns: True if the file descriptor was successfully removed from the set.

Remove a file descriptor from the file descriptor set.

restart

pollRestart Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a Poll.

-> m () 

Restart any pollWait 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 Poll objects created with gst_poll_new().

setControllable

pollSetControllable Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a Poll.

-> Bool

controllable: new controllable state.

-> m Bool

Returns: True if the controllability of set could be updated.

When controllable is True, this function ensures that future calls to pollWait will be affected by pollRestart and pollSetFlushing.

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

setFlushing

pollSetFlushing Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a Poll.

-> Bool

flushing: new flushing state.

-> m () 

When flushing is True, this function ensures that current and future calls to pollWait 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 Poll objects created with gst_poll_new().

wait

pollWait Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a Poll.

-> Word64

timeout: a timeout in nanoseconds.

-> m Int32

Returns: The number of 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.

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

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

writeControl

pollWriteControl Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Poll

set: a Poll.

-> m Bool

Returns: 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.

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

It will make any current and future pollWait function return with 1, meaning the control socket is set. After an equal amount of calls to pollReadControl have been performed, calls to pollWait will block again until their timeout expired.

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