{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) A 'GI.Gst.Structs.Poll.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 'GI.Gst.Structs.Poll.pollSetControllable'). New file descriptors are added to the set using 'GI.Gst.Structs.Poll.pollAddFd', and removed using 'GI.Gst.Structs.Poll.pollRemoveFd'. Controlling which file descriptors should be waited for to become readable and\/or writable are done using 'GI.Gst.Structs.Poll.pollFdCtlRead', 'GI.Gst.Structs.Poll.pollFdCtlWrite' and 'GI.Gst.Structs.Poll.pollFdCtlPri'. Use 'GI.Gst.Structs.Poll.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 'GI.Gst.Structs.Poll.pollRestart' and 'GI.Gst.Structs.Poll.pollSetFlushing'. Once the file descriptor set has been waited for, one can use 'GI.Gst.Structs.Poll.pollFdHasClosed' to see if the file descriptor has been closed, 'GI.Gst.Structs.Poll.pollFdHasError' to see if it has generated an error, 'GI.Gst.Structs.Poll.pollFdCanRead' to see if it is possible to read from the file descriptor, and 'GI.Gst.Structs.Poll.pollFdCanWrite' to see if it is possible to write to it. -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Gst.Structs.Poll ( -- * Exported types Poll(..) , noPoll , -- * Methods -- ** addFd #method:addFd# #if ENABLE_OVERLOADING PollAddFdMethodInfo , #endif pollAddFd , -- ** fdCanRead #method:fdCanRead# #if ENABLE_OVERLOADING PollFdCanReadMethodInfo , #endif pollFdCanRead , -- ** fdCanWrite #method:fdCanWrite# #if ENABLE_OVERLOADING PollFdCanWriteMethodInfo , #endif pollFdCanWrite , -- ** fdCtlPri #method:fdCtlPri# #if ENABLE_OVERLOADING PollFdCtlPriMethodInfo , #endif pollFdCtlPri , -- ** fdCtlRead #method:fdCtlRead# #if ENABLE_OVERLOADING PollFdCtlReadMethodInfo , #endif pollFdCtlRead , -- ** fdCtlWrite #method:fdCtlWrite# #if ENABLE_OVERLOADING PollFdCtlWriteMethodInfo , #endif pollFdCtlWrite , -- ** fdHasClosed #method:fdHasClosed# #if ENABLE_OVERLOADING PollFdHasClosedMethodInfo , #endif pollFdHasClosed , -- ** fdHasError #method:fdHasError# #if ENABLE_OVERLOADING PollFdHasErrorMethodInfo , #endif pollFdHasError , -- ** fdHasPri #method:fdHasPri# #if ENABLE_OVERLOADING PollFdHasPriMethodInfo , #endif pollFdHasPri , -- ** fdIgnored #method:fdIgnored# #if ENABLE_OVERLOADING PollFdIgnoredMethodInfo , #endif pollFdIgnored , -- ** getReadGpollfd #method:getReadGpollfd# #if ENABLE_OVERLOADING PollGetReadGpollfdMethodInfo , #endif pollGetReadGpollfd , -- ** readControl #method:readControl# #if ENABLE_OVERLOADING PollReadControlMethodInfo , #endif pollReadControl , -- ** removeFd #method:removeFd# #if ENABLE_OVERLOADING PollRemoveFdMethodInfo , #endif pollRemoveFd , -- ** restart #method:restart# #if ENABLE_OVERLOADING PollRestartMethodInfo , #endif pollRestart , -- ** setControllable #method:setControllable# #if ENABLE_OVERLOADING PollSetControllableMethodInfo , #endif pollSetControllable , -- ** setFlushing #method:setFlushing# #if ENABLE_OVERLOADING PollSetFlushingMethodInfo , #endif pollSetFlushing , -- ** wait #method:wait# #if ENABLE_OVERLOADING PollWaitMethodInfo , #endif pollWait , -- ** writeControl #method:writeControl# #if ENABLE_OVERLOADING PollWriteControlMethodInfo , #endif pollWriteControl , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GClosure as B.GClosure import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GValue as B.GValue import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.GI.Base.Properties as B.Properties import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import qualified GHC.OverloadedLabels as OL import qualified GI.GLib.Structs.PollFD as GLib.PollFD import {-# SOURCE #-} qualified GI.Gst.Structs.PollFD as Gst.PollFD -- | Memory-managed wrapper type. newtype Poll = Poll (ManagedPtr Poll) -- XXX Wrapping a foreign struct/union with no known destructor or size, leak? instance WrappedPtr Poll where wrappedPtrCalloc = return nullPtr wrappedPtrCopy = return wrappedPtrFree = Nothing -- | A convenience alias for `Nothing` :: `Maybe` `Poll`. noPoll :: Maybe Poll noPoll = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList Poll type instance O.AttributeList Poll = PollAttributeList type PollAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method Poll::add_fd -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_add_fd" gst_poll_add_fd :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) IO CInt {- | Add a file descriptor to the file descriptor set. -} pollAddFd :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> m Bool {- ^ __Returns:__ 'True' if the file descriptor was successfully added to the set. -} pollAddFd set fd = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd result <- gst_poll_add_fd set' fd' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollAddFdMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> m Bool), MonadIO m) => O.MethodInfo PollAddFdMethodInfo Poll signature where overloadedMethod _ = pollAddFd #endif -- method Poll::fd_can_read -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_fd_can_read" gst_poll_fd_can_read :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) IO CInt {- | Check if /@fd@/ in /@set@/ has data to be read. -} pollFdCanRead :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> m Bool {- ^ __Returns:__ 'True' if the descriptor has data to be read. -} pollFdCanRead set fd = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd result <- gst_poll_fd_can_read set' fd' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollFdCanReadMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> m Bool), MonadIO m) => O.MethodInfo PollFdCanReadMethodInfo Poll signature where overloadedMethod _ = pollFdCanRead #endif -- method Poll::fd_can_write -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_fd_can_write" gst_poll_fd_can_write :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) IO CInt {- | Check if /@fd@/ in /@set@/ can be used for writing. -} pollFdCanWrite :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> m Bool {- ^ __Returns:__ 'True' if the descriptor can be used for writing. -} pollFdCanWrite set fd = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd result <- gst_poll_fd_can_write set' fd' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollFdCanWriteMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> m Bool), MonadIO m) => O.MethodInfo PollFdCanWriteMethodInfo Poll signature where overloadedMethod _ = pollFdCanWrite #endif -- method Poll::fd_ctl_pri -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "active", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a new status.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_fd_ctl_pri" gst_poll_fd_ctl_pri :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) CInt -> -- active : TBasicType TBoolean IO CInt {- | 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/ -} pollFdCtlPri :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> Bool {- ^ /@active@/: a new status. -} -> m Bool {- ^ __Returns:__ 'True' if the descriptor was successfully updated. -} pollFdCtlPri set fd active = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd let active' = (fromIntegral . fromEnum) active result <- gst_poll_fd_ctl_pri set' fd' active' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollFdCtlPriMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> Bool -> m Bool), MonadIO m) => O.MethodInfo PollFdCtlPriMethodInfo Poll signature where overloadedMethod _ = pollFdCtlPri #endif -- method Poll::fd_ctl_read -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "active", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a new status.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_fd_ctl_read" gst_poll_fd_ctl_read :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) CInt -> -- active : TBasicType TBoolean IO CInt {- | Control whether the descriptor /@fd@/ in /@set@/ will be monitored for readability. -} pollFdCtlRead :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> Bool {- ^ /@active@/: a new status. -} -> m Bool {- ^ __Returns:__ 'True' if the descriptor was successfully updated. -} pollFdCtlRead set fd active = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd let active' = (fromIntegral . fromEnum) active result <- gst_poll_fd_ctl_read set' fd' active' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollFdCtlReadMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> Bool -> m Bool), MonadIO m) => O.MethodInfo PollFdCtlReadMethodInfo Poll signature where overloadedMethod _ = pollFdCtlRead #endif -- method Poll::fd_ctl_write -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "active", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a new status.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_fd_ctl_write" gst_poll_fd_ctl_write :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) CInt -> -- active : TBasicType TBoolean IO CInt {- | Control whether the descriptor /@fd@/ in /@set@/ will be monitored for writability. -} pollFdCtlWrite :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> Bool {- ^ /@active@/: a new status. -} -> m Bool {- ^ __Returns:__ 'True' if the descriptor was successfully updated. -} pollFdCtlWrite set fd active = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd let active' = (fromIntegral . fromEnum) active result <- gst_poll_fd_ctl_write set' fd' active' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollFdCtlWriteMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> Bool -> m Bool), MonadIO m) => O.MethodInfo PollFdCtlWriteMethodInfo Poll signature where overloadedMethod _ = pollFdCtlWrite #endif -- method Poll::fd_has_closed -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_fd_has_closed" gst_poll_fd_has_closed :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) IO CInt {- | Check if /@fd@/ in /@set@/ has closed the connection. -} pollFdHasClosed :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> m Bool {- ^ __Returns:__ 'True' if the connection was closed. -} pollFdHasClosed set fd = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd result <- gst_poll_fd_has_closed set' fd' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollFdHasClosedMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> m Bool), MonadIO m) => O.MethodInfo PollFdHasClosedMethodInfo Poll signature where overloadedMethod _ = pollFdHasClosed #endif -- method Poll::fd_has_error -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_fd_has_error" gst_poll_fd_has_error :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) IO CInt {- | Check if /@fd@/ in /@set@/ has an error. -} pollFdHasError :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> m Bool {- ^ __Returns:__ 'True' if the descriptor has an error. -} pollFdHasError set fd = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd result <- gst_poll_fd_has_error set' fd' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollFdHasErrorMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> m Bool), MonadIO m) => O.MethodInfo PollFdHasErrorMethodInfo Poll signature where overloadedMethod _ = pollFdHasError #endif -- method Poll::fd_has_pri -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_fd_has_pri" gst_poll_fd_has_pri :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) IO CInt {- | Check if /@fd@/ in /@set@/ has an exceptional condition (POLLPRI). Not implemented on Windows (will just return 'False' there). /Since: 1.16/ -} pollFdHasPri :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> m Bool {- ^ __Returns:__ 'True' if the descriptor has an exceptional condition. -} pollFdHasPri set fd = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd result <- gst_poll_fd_has_pri set' fd' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollFdHasPriMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> m Bool), MonadIO m) => O.MethodInfo PollFdHasPriMethodInfo Poll signature where overloadedMethod _ = pollFdHasPri #endif -- method Poll::fd_ignored -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "gst_poll_fd_ignored" gst_poll_fd_ignored :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) IO () {- | Mark /@fd@/ as ignored so that the next call to 'GI.Gst.Structs.Poll.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 'GI.Gst.Structs.Poll.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. -} pollFdIgnored :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> m () pollFdIgnored set fd = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd gst_poll_fd_ignored set' fd' touchManagedPtr set touchManagedPtr fd return () #if ENABLE_OVERLOADING data PollFdIgnoredMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> m ()), MonadIO m) => O.MethodInfo PollFdIgnoredMethodInfo Poll signature where overloadedMethod _ = pollFdIgnored #endif -- XXX Could not generate method Poll::free -- Error was : Bad introspection data: "Transferring a non-boxed struct with unknown size!" -- method Poll::get_read_gpollfd -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPoll", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "GLib", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GPollFD", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "gst_poll_get_read_gpollfd" gst_poll_get_read_gpollfd :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr GLib.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "GLib", name = "PollFD"}) IO () {- | Get a GPollFD for the reading part of the control socket. This is useful when integrating with a GSource and GMainLoop. -} pollGetReadGpollfd :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a 'GI.Gst.Structs.Poll.Poll' -} -> GLib.PollFD.PollFD {- ^ /@fd@/: a 'GI.GLib.Structs.PollFD.PollFD' -} -> m () pollGetReadGpollfd set fd = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd gst_poll_get_read_gpollfd set' fd' touchManagedPtr set touchManagedPtr fd return () #if ENABLE_OVERLOADING data PollGetReadGpollfdMethodInfo instance (signature ~ (GLib.PollFD.PollFD -> m ()), MonadIO m) => O.MethodInfo PollGetReadGpollfdMethodInfo Poll signature where overloadedMethod _ = pollGetReadGpollfd #endif -- method Poll::read_control -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPoll.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_read_control" gst_poll_read_control :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) IO CInt {- | Read a byte from the control socket of the controllable /@set@/. This function only works for timer 'GI.Gst.Structs.Poll.Poll' objects created with @/gst_poll_new_timer()/@. -} pollReadControl :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a 'GI.Gst.Structs.Poll.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. -} pollReadControl set = liftIO $ do set' <- unsafeManagedPtrGetPtr set result <- gst_poll_read_control set' let result' = (/= 0) result touchManagedPtr set return result' #if ENABLE_OVERLOADING data PollReadControlMethodInfo instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo PollReadControlMethodInfo Poll signature where overloadedMethod _ = pollReadControl #endif -- method Poll::remove_fd -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "Gst", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_remove_fd" gst_poll_remove_fd :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Ptr Gst.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "Gst", name = "PollFD"}) IO CInt {- | Remove a file descriptor from the file descriptor set. -} pollRemoveFd :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a file descriptor set. -} -> Gst.PollFD.PollFD {- ^ /@fd@/: a file descriptor. -} -> m Bool {- ^ __Returns:__ 'True' if the file descriptor was successfully removed from the set. -} pollRemoveFd set fd = liftIO $ do set' <- unsafeManagedPtrGetPtr set fd' <- unsafeManagedPtrGetPtr fd result <- gst_poll_remove_fd set' fd' let result' = (/= 0) result touchManagedPtr set touchManagedPtr fd return result' #if ENABLE_OVERLOADING data PollRemoveFdMethodInfo instance (signature ~ (Gst.PollFD.PollFD -> m Bool), MonadIO m) => O.MethodInfo PollRemoveFdMethodInfo Poll signature where overloadedMethod _ = pollRemoveFd #endif -- method Poll::restart -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPoll.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "gst_poll_restart" gst_poll_restart :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) IO () {- | Restart any 'GI.Gst.Structs.Poll.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 'GI.Gst.Structs.Poll.Poll' objects created with @/gst_poll_new()/@. -} pollRestart :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a 'GI.Gst.Structs.Poll.Poll'. -} -> m () pollRestart set = liftIO $ do set' <- unsafeManagedPtrGetPtr set gst_poll_restart set' touchManagedPtr set return () #if ENABLE_OVERLOADING data PollRestartMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo PollRestartMethodInfo Poll signature where overloadedMethod _ = pollRestart #endif -- method Poll::set_controllable -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPoll.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "controllable", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "new controllable state.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_set_controllable" gst_poll_set_controllable :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) CInt -> -- controllable : TBasicType TBoolean IO CInt {- | When /@controllable@/ is 'True', this function ensures that future calls to 'GI.Gst.Structs.Poll.pollWait' will be affected by 'GI.Gst.Structs.Poll.pollRestart' and 'GI.Gst.Structs.Poll.pollSetFlushing'. This function only works for non-timer 'GI.Gst.Structs.Poll.Poll' objects created with @/gst_poll_new()/@. -} pollSetControllable :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a 'GI.Gst.Structs.Poll.Poll'. -} -> Bool {- ^ /@controllable@/: new controllable state. -} -> m Bool {- ^ __Returns:__ 'True' if the controllability of /@set@/ could be updated. -} pollSetControllable set controllable = liftIO $ do set' <- unsafeManagedPtrGetPtr set let controllable' = (fromIntegral . fromEnum) controllable result <- gst_poll_set_controllable set' controllable' let result' = (/= 0) result touchManagedPtr set return result' #if ENABLE_OVERLOADING data PollSetControllableMethodInfo instance (signature ~ (Bool -> m Bool), MonadIO m) => O.MethodInfo PollSetControllableMethodInfo Poll signature where overloadedMethod _ = pollSetControllable #endif -- method Poll::set_flushing -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPoll.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flushing", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "new flushing state.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "gst_poll_set_flushing" gst_poll_set_flushing :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) CInt -> -- flushing : TBasicType TBoolean IO () {- | When /@flushing@/ is 'True', this function ensures that current and future calls to 'GI.Gst.Structs.Poll.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 'GI.Gst.Structs.Poll.Poll' objects created with @/gst_poll_new()/@. -} pollSetFlushing :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a 'GI.Gst.Structs.Poll.Poll'. -} -> Bool {- ^ /@flushing@/: new flushing state. -} -> m () pollSetFlushing set flushing = liftIO $ do set' <- unsafeManagedPtrGetPtr set let flushing' = (fromIntegral . fromEnum) flushing gst_poll_set_flushing set' flushing' touchManagedPtr set return () #if ENABLE_OVERLOADING data PollSetFlushingMethodInfo instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo PollSetFlushingMethodInfo Poll signature where overloadedMethod _ = pollSetFlushing #endif -- method Poll::wait -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPoll.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a timeout in nanoseconds.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "gst_poll_wait" gst_poll_wait :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) Word64 -> -- timeout : TBasicType TUInt64 IO Int32 {- | Wait for activity on the file descriptors in /@set@/. This function waits up to the specified /@timeout@/. A timeout of 'GI.Gst.Constants.CLOCK_TIME_NONE' waits forever. For 'GI.Gst.Structs.Poll.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 'GI.Gst.Structs.Poll.Poll' objects created with @/gst_poll_new_timer()/@, where it is allowed to have multiple threads waiting simultaneously. -} pollWait :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a 'GI.Gst.Structs.Poll.Poll'. -} -> Word64 {- ^ /@timeout@/: a timeout in nanoseconds. -} -> m Int32 {- ^ __Returns:__ The number of 'GI.Gst.Structs.PollFD.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. -} pollWait set timeout = liftIO $ do set' <- unsafeManagedPtrGetPtr set result <- gst_poll_wait set' timeout touchManagedPtr set return result #if ENABLE_OVERLOADING data PollWaitMethodInfo instance (signature ~ (Word64 -> m Int32), MonadIO m) => O.MethodInfo PollWaitMethodInfo Poll signature where overloadedMethod _ = pollWait #endif -- method Poll::write_control -- method type : OrdinaryMethod -- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Gst", name = "Poll"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPoll.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "gst_poll_write_control" gst_poll_write_control :: Ptr Poll -> -- set : TInterface (Name {namespace = "Gst", name = "Poll"}) IO CInt {- | Write a byte to the control socket of the controllable /@set@/. This function is mostly useful for timer 'GI.Gst.Structs.Poll.Poll' objects created with @/gst_poll_new_timer()/@. It will make any current and future 'GI.Gst.Structs.Poll.pollWait' function return with 1, meaning the control socket is set. After an equal amount of calls to 'GI.Gst.Structs.Poll.pollReadControl' have been performed, calls to 'GI.Gst.Structs.Poll.pollWait' will block again until their timeout expired. This function only works for timer 'GI.Gst.Structs.Poll.Poll' objects created with @/gst_poll_new_timer()/@. -} pollWriteControl :: (B.CallStack.HasCallStack, MonadIO m) => Poll {- ^ /@set@/: a 'GI.Gst.Structs.Poll.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. -} pollWriteControl set = liftIO $ do set' <- unsafeManagedPtrGetPtr set result <- gst_poll_write_control set' let result' = (/= 0) result touchManagedPtr set return result' #if ENABLE_OVERLOADING data PollWriteControlMethodInfo instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo PollWriteControlMethodInfo Poll signature where overloadedMethod _ = pollWriteControl #endif #if ENABLE_OVERLOADING type family ResolvePollMethod (t :: Symbol) (o :: *) :: * where ResolvePollMethod "addFd" o = PollAddFdMethodInfo ResolvePollMethod "fdCanRead" o = PollFdCanReadMethodInfo ResolvePollMethod "fdCanWrite" o = PollFdCanWriteMethodInfo ResolvePollMethod "fdCtlPri" o = PollFdCtlPriMethodInfo ResolvePollMethod "fdCtlRead" o = PollFdCtlReadMethodInfo ResolvePollMethod "fdCtlWrite" o = PollFdCtlWriteMethodInfo ResolvePollMethod "fdHasClosed" o = PollFdHasClosedMethodInfo ResolvePollMethod "fdHasError" o = PollFdHasErrorMethodInfo ResolvePollMethod "fdHasPri" o = PollFdHasPriMethodInfo ResolvePollMethod "fdIgnored" o = PollFdIgnoredMethodInfo ResolvePollMethod "readControl" o = PollReadControlMethodInfo ResolvePollMethod "removeFd" o = PollRemoveFdMethodInfo ResolvePollMethod "restart" o = PollRestartMethodInfo ResolvePollMethod "wait" o = PollWaitMethodInfo ResolvePollMethod "writeControl" o = PollWriteControlMethodInfo ResolvePollMethod "getReadGpollfd" o = PollGetReadGpollfdMethodInfo ResolvePollMethod "setControllable" o = PollSetControllableMethodInfo ResolvePollMethod "setFlushing" o = PollSetFlushingMethodInfo ResolvePollMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolvePollMethod t Poll, O.MethodInfo info Poll p) => OL.IsLabel t (Poll -> p) where #if MIN_VERSION_base(4,10,0) fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #else fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif #endif