{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Gst.Objects.Task.Task' is used by t'GI.Gst.Objects.Element.Element' and t'GI.Gst.Objects.Pad.Pad' to provide the data passing
-- threads in a t'GI.Gst.Objects.Pipeline.Pipeline'.
-- 
-- A t'GI.Gst.Objects.Pad.Pad' will typically start a t'GI.Gst.Objects.Task.Task' to push or pull data to\/from the
-- peer pads. Most source elements start a t'GI.Gst.Objects.Task.Task' to push data. In some cases
-- a demuxer element can start a t'GI.Gst.Objects.Task.Task' to pull data from a peer element. This
-- is typically done when the demuxer can perform random access on the upstream
-- peer element for improved performance.
-- 
-- Although convenience functions exist on t'GI.Gst.Objects.Pad.Pad' to start\/pause\/stop tasks, it
-- might sometimes be needed to create a t'GI.Gst.Objects.Task.Task' manually if it is not related to
-- a t'GI.Gst.Objects.Pad.Pad'.
-- 
-- Before the t'GI.Gst.Objects.Task.Task' can be run, it needs a t'GI.GLib.Structs.RecMutex.RecMutex' that can be set with
-- 'GI.Gst.Objects.Task.taskSetLock'.
-- 
-- The task can be started, paused and stopped with 'GI.Gst.Objects.Task.taskStart', 'GI.Gst.Objects.Task.taskPause'
-- and 'GI.Gst.Objects.Task.taskStop' respectively or with the 'GI.Gst.Objects.Task.taskSetState' function.
-- 
-- A t'GI.Gst.Objects.Task.Task' will repeatedly call the t'GI.Gst.Callbacks.TaskFunction' with the user data
-- that was provided when creating the task with 'GI.Gst.Objects.Task.taskNew'. While calling
-- the function it will acquire the provided lock. The provided lock is released
-- when the task pauses or stops.
-- 
-- Stopping a task with 'GI.Gst.Objects.Task.taskStop' will not immediately make sure the task is
-- not running anymore. Use 'GI.Gst.Objects.Task.taskJoin' to make sure the task is completely
-- stopped and the thread is stopped.
-- 
-- After creating a t'GI.Gst.Objects.Task.Task', use 'GI.Gst.Objects.Object.objectUnref' to free its resources. This can
-- only be done when the task is not running anymore.
-- 
-- Task functions can send a t'GI.Gst.Structs.Message.Message' to send out-of-band data to the
-- application. The application can receive messages from the t'GI.Gst.Objects.Bus.Bus' in its
-- mainloop.
-- 
-- For debugging purposes, the task will configure its object name as the thread
-- name on Linux. Please note that the object name should be configured before the
-- task is started; changing the object name after the task has been started, has
-- no effect on the thread name.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gst.Objects.Task
    ( 

-- * Exported types
    Task(..)                                ,
    IsTask                                  ,
    toTask                                  ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveTaskMethod                       ,
#endif


-- ** cleanupAll #method:cleanupAll#

    taskCleanupAll                          ,


-- ** getPool #method:getPool#

#if defined(ENABLE_OVERLOADING)
    TaskGetPoolMethodInfo                   ,
#endif
    taskGetPool                             ,


-- ** getState #method:getState#

#if defined(ENABLE_OVERLOADING)
    TaskGetStateMethodInfo                  ,
#endif
    taskGetState                            ,


-- ** join #method:join#

#if defined(ENABLE_OVERLOADING)
    TaskJoinMethodInfo                      ,
#endif
    taskJoin                                ,


-- ** new #method:new#

    taskNew                                 ,


-- ** pause #method:pause#

#if defined(ENABLE_OVERLOADING)
    TaskPauseMethodInfo                     ,
#endif
    taskPause                               ,


-- ** setEnterCallback #method:setEnterCallback#

#if defined(ENABLE_OVERLOADING)
    TaskSetEnterCallbackMethodInfo          ,
#endif
    taskSetEnterCallback                    ,


-- ** setLeaveCallback #method:setLeaveCallback#

#if defined(ENABLE_OVERLOADING)
    TaskSetLeaveCallbackMethodInfo          ,
#endif
    taskSetLeaveCallback                    ,


-- ** setLock #method:setLock#

#if defined(ENABLE_OVERLOADING)
    TaskSetLockMethodInfo                   ,
#endif
    taskSetLock                             ,


-- ** setPool #method:setPool#

#if defined(ENABLE_OVERLOADING)
    TaskSetPoolMethodInfo                   ,
#endif
    taskSetPool                             ,


-- ** setState #method:setState#

#if defined(ENABLE_OVERLOADING)
    TaskSetStateMethodInfo                  ,
#endif
    taskSetState                            ,


-- ** start #method:start#

#if defined(ENABLE_OVERLOADING)
    TaskStartMethodInfo                     ,
#endif
    taskStart                               ,


-- ** stop #method:stop#

#if defined(ENABLE_OVERLOADING)
    TaskStopMethodInfo                      ,
#endif
    taskStop                                ,




    ) 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.BasicTypes as B.Types
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.RecMutex as GLib.RecMutex
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gst.Callbacks as Gst.Callbacks
import {-# SOURCE #-} qualified GI.Gst.Enums as Gst.Enums
import {-# SOURCE #-} qualified GI.Gst.Objects.Object as Gst.Object
import {-# SOURCE #-} qualified GI.Gst.Objects.TaskPool as Gst.TaskPool

-- | Memory-managed wrapper type.
newtype Task = Task (SP.ManagedPtr Task)
    deriving (Task -> Task -> Bool
(Task -> Task -> Bool) -> (Task -> Task -> Bool) -> Eq Task
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Task -> Task -> Bool
$c/= :: Task -> Task -> Bool
== :: Task -> Task -> Bool
$c== :: Task -> Task -> Bool
Eq)

instance SP.ManagedPtrNewtype Task where
    toManagedPtr :: Task -> ManagedPtr Task
toManagedPtr (Task ManagedPtr Task
p) = ManagedPtr Task
p

foreign import ccall "gst_task_get_type"
    c_gst_task_get_type :: IO B.Types.GType

instance B.Types.TypedObject Task where
    glibType :: IO GType
glibType = IO GType
c_gst_task_get_type

instance B.Types.GObject Task

-- | Convert 'Task' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue Task where
    toGValue :: Task -> IO GValue
toGValue Task
o = do
        GType
gtype <- IO GType
c_gst_task_get_type
        Task -> (Ptr Task -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Task
o (GType -> (GValue -> Ptr Task -> IO ()) -> Ptr Task -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Task -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO Task
fromGValue GValue
gv = do
        Ptr Task
ptr <- GValue -> IO (Ptr Task)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Task)
        (ManagedPtr Task -> Task) -> Ptr Task -> IO Task
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Task -> Task
Task Ptr Task
ptr
        
    

-- | Type class for types which can be safely cast to `Task`, for instance with `toTask`.
class (SP.GObject o, O.IsDescendantOf Task o) => IsTask o
instance (SP.GObject o, O.IsDescendantOf Task o) => IsTask o

instance O.HasParentTypes Task
type instance O.ParentTypes Task = '[Gst.Object.Object, GObject.Object.Object]

-- | Cast to `Task`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toTask :: (MonadIO m, IsTask o) => o -> m Task
toTask :: o -> m Task
toTask = IO Task -> m Task
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Task -> m Task) -> (o -> IO Task) -> o -> m Task
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Task -> Task) -> o -> IO Task
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Task -> Task
Task

#if defined(ENABLE_OVERLOADING)
type family ResolveTaskMethod (t :: Symbol) (o :: *) :: * where
    ResolveTaskMethod "addControlBinding" o = Gst.Object.ObjectAddControlBindingMethodInfo
    ResolveTaskMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveTaskMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveTaskMethod "defaultError" o = Gst.Object.ObjectDefaultErrorMethodInfo
    ResolveTaskMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveTaskMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveTaskMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveTaskMethod "hasActiveControlBindings" o = Gst.Object.ObjectHasActiveControlBindingsMethodInfo
    ResolveTaskMethod "hasAncestor" o = Gst.Object.ObjectHasAncestorMethodInfo
    ResolveTaskMethod "hasAsAncestor" o = Gst.Object.ObjectHasAsAncestorMethodInfo
    ResolveTaskMethod "hasAsParent" o = Gst.Object.ObjectHasAsParentMethodInfo
    ResolveTaskMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveTaskMethod "join" o = TaskJoinMethodInfo
    ResolveTaskMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveTaskMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveTaskMethod "pause" o = TaskPauseMethodInfo
    ResolveTaskMethod "ref" o = Gst.Object.ObjectRefMethodInfo
    ResolveTaskMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveTaskMethod "removeControlBinding" o = Gst.Object.ObjectRemoveControlBindingMethodInfo
    ResolveTaskMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveTaskMethod "start" o = TaskStartMethodInfo
    ResolveTaskMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveTaskMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveTaskMethod "stop" o = TaskStopMethodInfo
    ResolveTaskMethod "suggestNextSync" o = Gst.Object.ObjectSuggestNextSyncMethodInfo
    ResolveTaskMethod "syncValues" o = Gst.Object.ObjectSyncValuesMethodInfo
    ResolveTaskMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveTaskMethod "unparent" o = Gst.Object.ObjectUnparentMethodInfo
    ResolveTaskMethod "unref" o = Gst.Object.ObjectUnrefMethodInfo
    ResolveTaskMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveTaskMethod "getControlBinding" o = Gst.Object.ObjectGetControlBindingMethodInfo
    ResolveTaskMethod "getControlRate" o = Gst.Object.ObjectGetControlRateMethodInfo
    ResolveTaskMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveTaskMethod "getGValueArray" o = Gst.Object.ObjectGetGValueArrayMethodInfo
    ResolveTaskMethod "getName" o = Gst.Object.ObjectGetNameMethodInfo
    ResolveTaskMethod "getParent" o = Gst.Object.ObjectGetParentMethodInfo
    ResolveTaskMethod "getPathString" o = Gst.Object.ObjectGetPathStringMethodInfo
    ResolveTaskMethod "getPool" o = TaskGetPoolMethodInfo
    ResolveTaskMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveTaskMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveTaskMethod "getState" o = TaskGetStateMethodInfo
    ResolveTaskMethod "getValue" o = Gst.Object.ObjectGetValueMethodInfo
    ResolveTaskMethod "setControlBindingDisabled" o = Gst.Object.ObjectSetControlBindingDisabledMethodInfo
    ResolveTaskMethod "setControlBindingsDisabled" o = Gst.Object.ObjectSetControlBindingsDisabledMethodInfo
    ResolveTaskMethod "setControlRate" o = Gst.Object.ObjectSetControlRateMethodInfo
    ResolveTaskMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveTaskMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveTaskMethod "setEnterCallback" o = TaskSetEnterCallbackMethodInfo
    ResolveTaskMethod "setLeaveCallback" o = TaskSetLeaveCallbackMethodInfo
    ResolveTaskMethod "setLock" o = TaskSetLockMethodInfo
    ResolveTaskMethod "setName" o = Gst.Object.ObjectSetNameMethodInfo
    ResolveTaskMethod "setParent" o = Gst.Object.ObjectSetParentMethodInfo
    ResolveTaskMethod "setPool" o = TaskSetPoolMethodInfo
    ResolveTaskMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveTaskMethod "setState" o = TaskSetStateMethodInfo
    ResolveTaskMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveTaskMethod t Task, O.MethodInfo info Task p) => OL.IsLabel t (Task -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Task
type instance O.AttributeList Task = TaskAttributeList
type TaskAttributeList = ('[ '("name", Gst.Object.ObjectNamePropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Task = TaskSignalList
type TaskSignalList = ('[ '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Task::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "func"
--           , argType =
--               TInterface Name { namespace = "Gst" , name = "TaskFunction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GstTaskFunction to use"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeNotified
--           , argClosure = 1
--           , argDestroy = 2
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "User data to pass to @func"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "notify"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "DestroyNotify" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the function to call when @user_data is no longer needed."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Task" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_task_new" gst_task_new :: 
    FunPtr Gst.Callbacks.C_TaskFunction ->  -- func : TInterface (Name {namespace = "Gst", name = "TaskFunction"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO (Ptr Task)

-- | Create a new Task that will repeatedly call the provided /@func@/
-- with /@userData@/ as a parameter. Typically the task will run in
-- a new thread.
-- 
-- The function cannot be changed after the task has been created. You
-- must create a new t'GI.Gst.Objects.Task.Task' to change the function.
-- 
-- This function will not yet create and start a thread. Use 'GI.Gst.Objects.Task.taskStart' or
-- 'GI.Gst.Objects.Task.taskPause' to create and start the GThread.
-- 
-- Before the task can be used, a t'GI.GLib.Structs.RecMutex.RecMutex' must be configured using the
-- 'GI.Gst.Objects.Task.taskSetLock' function. This lock will always be acquired while
-- /@func@/ is called.
taskNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Callbacks.TaskFunction
    -- ^ /@func@/: The t'GI.Gst.Callbacks.TaskFunction' to use
    -> m Task
    -- ^ __Returns:__ A new t'GI.Gst.Objects.Task.Task'.
    -- 
    -- MT safe.
taskNew :: IO () -> m Task
taskNew IO ()
func = IO Task -> m Task
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Task -> m Task) -> IO Task -> m Task
forall a b. (a -> b) -> a -> b
$ do
    FunPtr C_TaskFunction
func' <- C_TaskFunction -> IO (FunPtr C_TaskFunction)
Gst.Callbacks.mk_TaskFunction (Maybe (Ptr (FunPtr C_TaskFunction))
-> C_TaskFunction -> C_TaskFunction
Gst.Callbacks.wrap_TaskFunction Maybe (Ptr (FunPtr C_TaskFunction))
forall a. Maybe a
Nothing (IO () -> C_TaskFunction
Gst.Callbacks.drop_closures_TaskFunction IO ()
func))
    let userData :: Ptr ()
userData = FunPtr C_TaskFunction -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_TaskFunction
func'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Ptr Task
result <- FunPtr C_TaskFunction
-> Ptr () -> FunPtr C_TaskFunction -> IO (Ptr Task)
gst_task_new FunPtr C_TaskFunction
func' Ptr ()
userData FunPtr C_TaskFunction
forall a. FunPtr (Ptr a -> IO ())
notify
    Text -> Ptr Task -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"taskNew" Ptr Task
result
    Task
result' <- ((ManagedPtr Task -> Task) -> Ptr Task -> IO Task
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Task -> Task
Task) Ptr Task
result
    Task -> IO Task
forall (m :: * -> *) a. Monad m => a -> m a
return Task
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method Task::get_pool
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstTask" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "TaskPool" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_task_get_pool" gst_task_get_pool :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    IO (Ptr Gst.TaskPool.TaskPool)

-- | Get the t'GI.Gst.Objects.TaskPool.TaskPool' that this task will use for its streaming
-- threads.
-- 
-- MT safe.
taskGetPool ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: a t'GI.Gst.Objects.Task.Task'
    -> m Gst.TaskPool.TaskPool
    -- ^ __Returns:__ the t'GI.Gst.Objects.TaskPool.TaskPool' used by /@task@/. 'GI.Gst.Objects.Object.objectUnref'
    -- after usage.
taskGetPool :: a -> m TaskPool
taskGetPool a
task = IO TaskPool -> m TaskPool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TaskPool -> m TaskPool) -> IO TaskPool -> m TaskPool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    Ptr TaskPool
result <- Ptr Task -> IO (Ptr TaskPool)
gst_task_get_pool Ptr Task
task'
    Text -> Ptr TaskPool -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"taskGetPool" Ptr TaskPool
result
    TaskPool
result' <- ((ManagedPtr TaskPool -> TaskPool) -> Ptr TaskPool -> IO TaskPool
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr TaskPool -> TaskPool
Gst.TaskPool.TaskPool) Ptr TaskPool
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    TaskPool -> IO TaskPool
forall (m :: * -> *) a. Monad m => a -> m a
return TaskPool
result'

#if defined(ENABLE_OVERLOADING)
data TaskGetPoolMethodInfo
instance (signature ~ (m Gst.TaskPool.TaskPool), MonadIO m, IsTask a) => O.MethodInfo TaskGetPoolMethodInfo a signature where
    overloadedMethod = taskGetPool

#endif

-- method Task::get_state
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GstTask to query"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "TaskState" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_task_get_state" gst_task_get_state :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    IO CUInt

-- | Get the current state of the task.
taskGetState ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: The t'GI.Gst.Objects.Task.Task' to query
    -> m Gst.Enums.TaskState
    -- ^ __Returns:__ The t'GI.Gst.Enums.TaskState' of the task
    -- 
    -- MT safe.
taskGetState :: a -> m TaskState
taskGetState a
task = IO TaskState -> m TaskState
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TaskState -> m TaskState) -> IO TaskState -> m TaskState
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    CUInt
result <- Ptr Task -> IO CUInt
gst_task_get_state Ptr Task
task'
    let result' :: TaskState
result' = (Int -> TaskState
forall a. Enum a => Int -> a
toEnum (Int -> TaskState) -> (CUInt -> Int) -> CUInt -> TaskState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    TaskState -> IO TaskState
forall (m :: * -> *) a. Monad m => a -> m a
return TaskState
result'

#if defined(ENABLE_OVERLOADING)
data TaskGetStateMethodInfo
instance (signature ~ (m Gst.Enums.TaskState), MonadIO m, IsTask a) => O.MethodInfo TaskGetStateMethodInfo a signature where
    overloadedMethod = taskGetState

#endif

-- method Task::join
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GstTask to join"
--                 , 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_task_join" gst_task_join :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    IO CInt

-- | Joins /@task@/. After this call, it is safe to unref the task
-- and clean up the lock set with 'GI.Gst.Objects.Task.taskSetLock'.
-- 
-- The task will automatically be stopped with this call.
-- 
-- This function cannot be called from within a task function as this
-- would cause a deadlock. The function will detect this and print a
-- g_warning.
taskJoin ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: The t'GI.Gst.Objects.Task.Task' to join
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the task could be joined.
    -- 
    -- MT safe.
taskJoin :: a -> m Bool
taskJoin a
task = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    CInt
result <- Ptr Task -> IO CInt
gst_task_join Ptr Task
task'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data TaskJoinMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskJoinMethodInfo a signature where
    overloadedMethod = taskJoin

#endif

-- method Task::pause
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GstTask to pause"
--                 , 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_task_pause" gst_task_pause :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    IO CInt

-- | Pauses /@task@/. This method can also be called on a task in the
-- stopped state, in which case a thread will be started and will remain
-- in the paused state. This function does not wait for the task to complete
-- the paused state.
taskPause ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: The t'GI.Gst.Objects.Task.Task' to pause
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the task could be paused.
    -- 
    -- MT safe.
taskPause :: a -> m Bool
taskPause a
task = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    CInt
result <- Ptr Task -> IO CInt
gst_task_pause Ptr Task
task'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data TaskPauseMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskPauseMethodInfo a signature where
    overloadedMethod = taskPause

#endif

-- method Task::set_enter_callback
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GstTask to use"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "enter_func"
--           , argType =
--               TInterface Name { namespace = "Gst" , name = "TaskThreadFunc" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstTaskThreadFunc"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeNotified
--           , argClosure = 2
--           , argDestroy = 3
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data passed to @enter_func"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "notify"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "DestroyNotify" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "called when @user_data is no longer referenced"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_task_set_enter_callback" gst_task_set_enter_callback :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    FunPtr Gst.Callbacks.C_TaskThreadFunc -> -- enter_func : TInterface (Name {namespace = "Gst", name = "TaskThreadFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

-- | Call /@enterFunc@/ when the task function of /@task@/ is entered. /@userData@/ will
-- be passed to /@enterFunc@/ and /@notify@/ will be called when /@userData@/ is no
-- longer referenced.
taskSetEnterCallback ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: The t'GI.Gst.Objects.Task.Task' to use
    -> Gst.Callbacks.TaskThreadFunc
    -- ^ /@enterFunc@/: a t'GI.Gst.Callbacks.TaskThreadFunc'
    -> m ()
taskSetEnterCallback :: a -> TaskThreadFunc -> m ()
taskSetEnterCallback a
task TaskThreadFunc
enterFunc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    FunPtr C_TaskThreadFunc
enterFunc' <- C_TaskThreadFunc -> IO (FunPtr C_TaskThreadFunc)
Gst.Callbacks.mk_TaskThreadFunc (Maybe (Ptr (FunPtr C_TaskThreadFunc))
-> TaskThreadFunc_WithClosures -> C_TaskThreadFunc
Gst.Callbacks.wrap_TaskThreadFunc Maybe (Ptr (FunPtr C_TaskThreadFunc))
forall a. Maybe a
Nothing (TaskThreadFunc -> TaskThreadFunc_WithClosures
Gst.Callbacks.drop_closures_TaskThreadFunc TaskThreadFunc
enterFunc))
    let userData :: Ptr ()
userData = FunPtr C_TaskThreadFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_TaskThreadFunc
enterFunc'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Ptr Task
-> FunPtr C_TaskThreadFunc
-> Ptr ()
-> FunPtr C_TaskFunction
-> IO ()
gst_task_set_enter_callback Ptr Task
task' FunPtr C_TaskThreadFunc
enterFunc' Ptr ()
userData FunPtr C_TaskFunction
forall a. FunPtr (Ptr a -> IO ())
notify
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TaskSetEnterCallbackMethodInfo
instance (signature ~ (Gst.Callbacks.TaskThreadFunc -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskSetEnterCallbackMethodInfo a signature where
    overloadedMethod = taskSetEnterCallback

#endif

-- method Task::set_leave_callback
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GstTask to use"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "leave_func"
--           , argType =
--               TInterface Name { namespace = "Gst" , name = "TaskThreadFunc" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstTaskThreadFunc"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeNotified
--           , argClosure = 2
--           , argDestroy = 3
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data passed to @leave_func"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "notify"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "DestroyNotify" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "called when @user_data is no longer referenced"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_task_set_leave_callback" gst_task_set_leave_callback :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    FunPtr Gst.Callbacks.C_TaskThreadFunc -> -- leave_func : TInterface (Name {namespace = "Gst", name = "TaskThreadFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

-- | Call /@leaveFunc@/ when the task function of /@task@/ is left. /@userData@/ will
-- be passed to /@leaveFunc@/ and /@notify@/ will be called when /@userData@/ is no
-- longer referenced.
taskSetLeaveCallback ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: The t'GI.Gst.Objects.Task.Task' to use
    -> Gst.Callbacks.TaskThreadFunc
    -- ^ /@leaveFunc@/: a t'GI.Gst.Callbacks.TaskThreadFunc'
    -> m ()
taskSetLeaveCallback :: a -> TaskThreadFunc -> m ()
taskSetLeaveCallback a
task TaskThreadFunc
leaveFunc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    FunPtr C_TaskThreadFunc
leaveFunc' <- C_TaskThreadFunc -> IO (FunPtr C_TaskThreadFunc)
Gst.Callbacks.mk_TaskThreadFunc (Maybe (Ptr (FunPtr C_TaskThreadFunc))
-> TaskThreadFunc_WithClosures -> C_TaskThreadFunc
Gst.Callbacks.wrap_TaskThreadFunc Maybe (Ptr (FunPtr C_TaskThreadFunc))
forall a. Maybe a
Nothing (TaskThreadFunc -> TaskThreadFunc_WithClosures
Gst.Callbacks.drop_closures_TaskThreadFunc TaskThreadFunc
leaveFunc))
    let userData :: Ptr ()
userData = FunPtr C_TaskThreadFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_TaskThreadFunc
leaveFunc'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Ptr Task
-> FunPtr C_TaskThreadFunc
-> Ptr ()
-> FunPtr C_TaskFunction
-> IO ()
gst_task_set_leave_callback Ptr Task
task' FunPtr C_TaskThreadFunc
leaveFunc' Ptr ()
userData FunPtr C_TaskFunction
forall a. FunPtr (Ptr a -> IO ())
notify
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TaskSetLeaveCallbackMethodInfo
instance (signature ~ (Gst.Callbacks.TaskThreadFunc -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskSetLeaveCallbackMethodInfo a signature where
    overloadedMethod = taskSetLeaveCallback

#endif

-- method Task::set_lock
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GstTask to use"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "mutex"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "RecMutex" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GRecMutex to use"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_task_set_lock" gst_task_set_lock :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    Ptr GLib.RecMutex.RecMutex ->           -- mutex : TInterface (Name {namespace = "GLib", name = "RecMutex"})
    IO ()

-- | Set the mutex used by the task. The mutex will be acquired before
-- calling the t'GI.Gst.Callbacks.TaskFunction'.
-- 
-- This function has to be called before calling 'GI.Gst.Objects.Task.taskPause' or
-- 'GI.Gst.Objects.Task.taskStart'.
-- 
-- MT safe.
taskSetLock ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: The t'GI.Gst.Objects.Task.Task' to use
    -> GLib.RecMutex.RecMutex
    -- ^ /@mutex@/: The t'GI.GLib.Structs.RecMutex.RecMutex' to use
    -> m ()
taskSetLock :: a -> RecMutex -> m ()
taskSetLock a
task RecMutex
mutex = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    Ptr RecMutex
mutex' <- RecMutex -> IO (Ptr RecMutex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr RecMutex
mutex
    Ptr Task -> Ptr RecMutex -> IO ()
gst_task_set_lock Ptr Task
task' Ptr RecMutex
mutex'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    RecMutex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr RecMutex
mutex
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TaskSetLockMethodInfo
instance (signature ~ (GLib.RecMutex.RecMutex -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskSetLockMethodInfo a signature where
    overloadedMethod = taskSetLock

#endif

-- method Task::set_pool
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstTask" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "pool"
--           , argType =
--               TInterface Name { namespace = "Gst" , name = "TaskPool" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstTaskPool" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_task_set_pool" gst_task_set_pool :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    Ptr Gst.TaskPool.TaskPool ->            -- pool : TInterface (Name {namespace = "Gst", name = "TaskPool"})
    IO ()

-- | Set /@pool@/ as the new GstTaskPool for /@task@/. Any new streaming threads that
-- will be created by /@task@/ will now use /@pool@/.
-- 
-- MT safe.
taskSetPool ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a, Gst.TaskPool.IsTaskPool b) =>
    a
    -- ^ /@task@/: a t'GI.Gst.Objects.Task.Task'
    -> b
    -- ^ /@pool@/: a t'GI.Gst.Objects.TaskPool.TaskPool'
    -> m ()
taskSetPool :: a -> b -> m ()
taskSetPool a
task b
pool = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    Ptr TaskPool
pool' <- b -> IO (Ptr TaskPool)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
pool
    Ptr Task -> Ptr TaskPool -> IO ()
gst_task_set_pool Ptr Task
task' Ptr TaskPool
pool'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
pool
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TaskSetPoolMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsTask a, Gst.TaskPool.IsTaskPool b) => O.MethodInfo TaskSetPoolMethodInfo a signature where
    overloadedMethod = taskSetPool

#endif

-- method Task::set_state
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstTask" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "state"
--           , argType =
--               TInterface Name { namespace = "Gst" , name = "TaskState" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the new task 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_task_set_state" gst_task_set_state :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    CUInt ->                                -- state : TInterface (Name {namespace = "Gst", name = "TaskState"})
    IO CInt

-- | Sets the state of /@task@/ to /@state@/.
-- 
-- The /@task@/ must have a lock associated with it using
-- 'GI.Gst.Objects.Task.taskSetLock' when going to GST_TASK_STARTED or GST_TASK_PAUSED or
-- this function will return 'P.False'.
-- 
-- MT safe.
taskSetState ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: a t'GI.Gst.Objects.Task.Task'
    -> Gst.Enums.TaskState
    -- ^ /@state@/: the new task state
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the state could be changed.
taskSetState :: a -> TaskState -> m Bool
taskSetState a
task TaskState
state = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    let state' :: CUInt
state' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (TaskState -> Int) -> TaskState -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TaskState -> Int
forall a. Enum a => a -> Int
fromEnum) TaskState
state
    CInt
result <- Ptr Task -> CUInt -> IO CInt
gst_task_set_state Ptr Task
task' CUInt
state'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data TaskSetStateMethodInfo
instance (signature ~ (Gst.Enums.TaskState -> m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskSetStateMethodInfo a signature where
    overloadedMethod = taskSetState

#endif

-- method Task::start
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GstTask to start"
--                 , 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_task_start" gst_task_start :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    IO CInt

-- | Starts /@task@/. The /@task@/ must have a lock associated with it using
-- 'GI.Gst.Objects.Task.taskSetLock' or this function will return 'P.False'.
taskStart ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: The t'GI.Gst.Objects.Task.Task' to start
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the task could be started.
    -- 
    -- MT safe.
taskStart :: a -> m Bool
taskStart a
task = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    CInt
result <- Ptr Task -> IO CInt
gst_task_start Ptr Task
task'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data TaskStartMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskStartMethodInfo a signature where
    overloadedMethod = taskStart

#endif

-- method Task::stop
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "task"
--           , argType = TInterface Name { namespace = "Gst" , name = "Task" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The #GstTask to stop"
--                 , 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_task_stop" gst_task_stop :: 
    Ptr Task ->                             -- task : TInterface (Name {namespace = "Gst", name = "Task"})
    IO CInt

-- | Stops /@task@/. This method merely schedules the task to stop and
-- will not wait for the task to have completely stopped. Use
-- 'GI.Gst.Objects.Task.taskJoin' to stop and wait for completion.
taskStop ::
    (B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
    a
    -- ^ /@task@/: The t'GI.Gst.Objects.Task.Task' to stop
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the task could be stopped.
    -- 
    -- MT safe.
taskStop :: a -> m Bool
taskStop a
task = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Task
task' <- a -> IO (Ptr Task)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
task
    CInt
result <- Ptr Task -> IO CInt
gst_task_stop Ptr Task
task'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
task
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data TaskStopMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskStopMethodInfo a signature where
    overloadedMethod = taskStop

#endif

-- method Task::cleanup_all
-- method type : MemberFunction
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_task_cleanup_all" gst_task_cleanup_all :: 
    IO ()

-- | Wait for all tasks to be stopped. This is mainly used internally
-- to ensure proper cleanup of internal data structures in test suites.
-- 
-- MT safe.
taskCleanupAll ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
taskCleanupAll :: m ()
taskCleanupAll  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
gst_task_cleanup_all
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
#endif