{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) 'GI.Gst.Objects.Task.Task' is used by 'GI.Gst.Objects.Element.Element' and 'GI.Gst.Objects.Pad.Pad' to provide the data passing threads in a 'GI.Gst.Objects.Pipeline.Pipeline'. A 'GI.Gst.Objects.Pad.Pad' will typically start a 'GI.Gst.Objects.Task.Task' to push or pull data to\/from the peer pads. Most source elements start a 'GI.Gst.Objects.Task.Task' to push data. In some cases a demuxer element can start a '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 'GI.Gst.Objects.Pad.Pad' to start\/pause\/stop tasks, it might sometimes be needed to create a 'GI.Gst.Objects.Task.Task' manually if it is not related to a 'GI.Gst.Objects.Pad.Pad'. Before the 'GI.Gst.Objects.Task.Task' can be run, it needs a '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 'GI.Gst.Objects.Task.Task' will repeatedly call the '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 '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 'GI.Gst.Structs.Message.Message' to send out-of-band data to the application. The application can receive messages from the '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. -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Gst.Objects.Task ( -- * Exported types Task(..) , IsTask , toTask , noTask , -- * Methods -- ** cleanupAll #method:cleanupAll# taskCleanupAll , -- ** getPool #method:getPool# #if ENABLE_OVERLOADING TaskGetPoolMethodInfo , #endif taskGetPool , -- ** getState #method:getState# #if ENABLE_OVERLOADING TaskGetStateMethodInfo , #endif taskGetState , -- ** join #method:join# #if ENABLE_OVERLOADING TaskJoinMethodInfo , #endif taskJoin , -- ** new #method:new# taskNew , -- ** pause #method:pause# #if ENABLE_OVERLOADING TaskPauseMethodInfo , #endif taskPause , -- ** setEnterCallback #method:setEnterCallback# #if ENABLE_OVERLOADING TaskSetEnterCallbackMethodInfo , #endif taskSetEnterCallback , -- ** setLeaveCallback #method:setLeaveCallback# #if ENABLE_OVERLOADING TaskSetLeaveCallbackMethodInfo , #endif taskSetLeaveCallback , -- ** setLock #method:setLock# #if ENABLE_OVERLOADING TaskSetLockMethodInfo , #endif taskSetLock , -- ** setPool #method:setPool# #if ENABLE_OVERLOADING TaskSetPoolMethodInfo , #endif taskSetPool , -- ** setState #method:setState# #if ENABLE_OVERLOADING TaskSetStateMethodInfo , #endif taskSetState , -- ** start #method:start# #if ENABLE_OVERLOADING TaskStartMethodInfo , #endif taskStart , -- ** stop #method:stop# #if 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.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.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 (ManagedPtr Task) foreign import ccall "gst_task_get_type" c_gst_task_get_type :: IO GType instance GObject Task where gobjectType = c_gst_task_get_type -- | Type class for types which can be safely cast to `Task`, for instance with `toTask`. class (GObject o, O.IsDescendantOf Task o) => IsTask o instance (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 = liftIO . unsafeCastTo Task -- | A convenience alias for `Nothing` :: `Maybe` `Task`. noTask :: Maybe Task noTask = Nothing #if 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 "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 (O.MethodProxy :: O.MethodProxy info) #else fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif #endif #if 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 ENABLE_OVERLOADING #endif #if 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 '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 '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 'GI.Gst.Callbacks.TaskFunction' to use -} -> m Task {- ^ __Returns:__ A new 'GI.Gst.Objects.Task.Task'. MT safe. -} taskNew func = liftIO $ do func' <- Gst.Callbacks.mk_TaskFunction (Gst.Callbacks.wrap_TaskFunction Nothing (Gst.Callbacks.drop_closures_TaskFunction func)) let userData = castFunPtrToPtr func' let notify = safeFreeFunPtrPtr result <- gst_task_new func' userData notify checkUnexpectedReturnNULL "taskNew" result result' <- (wrapObject Task) result return result' #if 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 '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 'GI.Gst.Objects.Task.Task' -} -> m Gst.TaskPool.TaskPool {- ^ __Returns:__ the 'GI.Gst.Objects.TaskPool.TaskPool' used by /@task@/. 'GI.Gst.Objects.Object.objectUnref' after usage. -} taskGetPool task = liftIO $ do task' <- unsafeManagedPtrCastPtr task result <- gst_task_get_pool task' checkUnexpectedReturnNULL "taskGetPool" result result' <- (wrapObject Gst.TaskPool.TaskPool) result touchManagedPtr task return result' #if 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 'GI.Gst.Objects.Task.Task' to query -} -> m Gst.Enums.TaskState {- ^ __Returns:__ The 'GI.Gst.Enums.TaskState' of the task MT safe. -} taskGetState task = liftIO $ do task' <- unsafeManagedPtrCastPtr task result <- gst_task_get_state task' let result' = (toEnum . fromIntegral) result touchManagedPtr task return result' #if 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 'GI.Gst.Objects.Task.Task' to join -} -> m Bool {- ^ __Returns:__ 'True' if the task could be joined. MT safe. -} taskJoin task = liftIO $ do task' <- unsafeManagedPtrCastPtr task result <- gst_task_join task' let result' = (/= 0) result touchManagedPtr task return result' #if 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 'GI.Gst.Objects.Task.Task' to pause -} -> m Bool {- ^ __Returns:__ 'True' if the task could be paused. MT safe. -} taskPause task = liftIO $ do task' <- unsafeManagedPtrCastPtr task result <- gst_task_pause task' let result' = (/= 0) result touchManagedPtr task return result' #if 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 'GI.Gst.Objects.Task.Task' to use -} -> Gst.Callbacks.TaskThreadFunc {- ^ /@enterFunc@/: a 'GI.Gst.Callbacks.TaskThreadFunc' -} -> m () taskSetEnterCallback task enterFunc = liftIO $ do task' <- unsafeManagedPtrCastPtr task enterFunc' <- Gst.Callbacks.mk_TaskThreadFunc (Gst.Callbacks.wrap_TaskThreadFunc Nothing (Gst.Callbacks.drop_closures_TaskThreadFunc enterFunc)) let userData = castFunPtrToPtr enterFunc' let notify = safeFreeFunPtrPtr gst_task_set_enter_callback task' enterFunc' userData notify touchManagedPtr task return () #if 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 'GI.Gst.Objects.Task.Task' to use -} -> Gst.Callbacks.TaskThreadFunc {- ^ /@leaveFunc@/: a 'GI.Gst.Callbacks.TaskThreadFunc' -} -> m () taskSetLeaveCallback task leaveFunc = liftIO $ do task' <- unsafeManagedPtrCastPtr task leaveFunc' <- Gst.Callbacks.mk_TaskThreadFunc (Gst.Callbacks.wrap_TaskThreadFunc Nothing (Gst.Callbacks.drop_closures_TaskThreadFunc leaveFunc)) let userData = castFunPtrToPtr leaveFunc' let notify = safeFreeFunPtrPtr gst_task_set_leave_callback task' leaveFunc' userData notify touchManagedPtr task return () #if 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 '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 'GI.Gst.Objects.Task.Task' to use -} -> GLib.RecMutex.RecMutex {- ^ /@mutex@/: The 'GI.GLib.Structs.RecMutex.RecMutex' to use -} -> m () taskSetLock task mutex = liftIO $ do task' <- unsafeManagedPtrCastPtr task mutex' <- unsafeManagedPtrGetPtr mutex gst_task_set_lock task' mutex' touchManagedPtr task touchManagedPtr mutex return () #if 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 'GI.Gst.Objects.Task.Task' -} -> b {- ^ /@pool@/: a 'GI.Gst.Objects.TaskPool.TaskPool' -} -> m () taskSetPool task pool = liftIO $ do task' <- unsafeManagedPtrCastPtr task pool' <- unsafeManagedPtrCastPtr pool gst_task_set_pool task' pool' touchManagedPtr task touchManagedPtr pool return () #if 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 'False'. MT safe. -} taskSetState :: (B.CallStack.HasCallStack, MonadIO m, IsTask a) => a {- ^ /@task@/: a 'GI.Gst.Objects.Task.Task' -} -> Gst.Enums.TaskState {- ^ /@state@/: the new task state -} -> m Bool {- ^ __Returns:__ 'True' if the state could be changed. -} taskSetState task state = liftIO $ do task' <- unsafeManagedPtrCastPtr task let state' = (fromIntegral . fromEnum) state result <- gst_task_set_state task' state' let result' = (/= 0) result touchManagedPtr task return result' #if 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 'False'. -} taskStart :: (B.CallStack.HasCallStack, MonadIO m, IsTask a) => a {- ^ /@task@/: The 'GI.Gst.Objects.Task.Task' to start -} -> m Bool {- ^ __Returns:__ 'True' if the task could be started. MT safe. -} taskStart task = liftIO $ do task' <- unsafeManagedPtrCastPtr task result <- gst_task_start task' let result' = (/= 0) result touchManagedPtr task return result' #if 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 'GI.Gst.Objects.Task.Task' to stop -} -> m Bool {- ^ __Returns:__ 'True' if the task could be stopped. MT safe. -} taskStop task = liftIO $ do task' <- unsafeManagedPtrCastPtr task result <- gst_task_stop task' let result' = (/= 0) result touchManagedPtr task return result' #if 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 = liftIO $ do gst_task_cleanup_all return () #if ENABLE_OVERLOADING #endif