gi-gst-1.0.23: GStreamer bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gst.Objects.Task

Description

Task is used by Element and Pad to provide the data passing threads in a Pipeline.

A Pad will typically start a Task to push or pull data to/from the peer pads. Most source elements start a Task to push data. In some cases a demuxer element can start a 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 Pad to start/pause/stop tasks, it might sometimes be needed to create a Task manually if it is not related to a Pad.

Before the Task can be run, it needs a RecMutex that can be set with taskSetLock.

The task can be started, paused and stopped with taskStart, taskPause and taskStop respectively or with the taskSetState function.

A Task will repeatedly call the TaskFunction with the user data that was provided when creating the task with 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 taskStop will not immediately make sure the task is not running anymore. Use taskJoin to make sure the task is completely stopped and the thread is stopped.

After creating a Task, use objectUnref to free its resources. This can only be done when the task is not running anymore.

Task functions can send a Message to send out-of-band data to the application. The application can receive messages from the 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.

Synopsis

Exported types

newtype Task Source #

Memory-managed wrapper type.

Constructors

Task (ManagedPtr Task) 

Instances

Instances details
Eq Task Source # 
Instance details

Defined in GI.Gst.Objects.Task

Methods

(==) :: Task -> Task -> Bool

(/=) :: Task -> Task -> Bool

GObject Task Source # 
Instance details

Defined in GI.Gst.Objects.Task

ManagedPtrNewtype Task Source # 
Instance details

Defined in GI.Gst.Objects.Task

Methods

toManagedPtr :: Task -> ManagedPtr Task

TypedObject Task Source # 
Instance details

Defined in GI.Gst.Objects.Task

Methods

glibType :: IO GType

IsGValue Task Source #

Convert Task to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gst.Objects.Task

Methods

toGValue :: Task -> IO GValue

fromGValue :: GValue -> IO Task

HasParentTypes Task Source # 
Instance details

Defined in GI.Gst.Objects.Task

type ParentTypes Task Source # 
Instance details

Defined in GI.Gst.Objects.Task

type ParentTypes Task = '[Object, Object]

class (GObject o, IsDescendantOf Task o) => IsTask o Source #

Type class for types which can be safely cast to Task, for instance with toTask.

Instances

Instances details
(GObject o, IsDescendantOf Task o) => IsTask o Source # 
Instance details

Defined in GI.Gst.Objects.Task

toTask :: (MonadIO m, IsTask o) => o -> m Task Source #

Cast to Task, for types for which this is known to be safe. For general casts, use castTo.

Methods

Overloaded methods

cleanupAll

taskCleanupAll :: (HasCallStack, MonadIO m) => m () Source #

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.

getPool

taskGetPool Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: a Task

-> m TaskPool

Returns: the TaskPool used by task. objectUnref after usage.

Get the TaskPool that this task will use for its streaming threads.

MT safe.

getState

taskGetState Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: The Task to query

-> m TaskState

Returns: The TaskState of the task

MT safe.

Get the current state of the task.

join

taskJoin Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: The Task to join

-> m Bool

Returns: True if the task could be joined.

MT safe.

Joins task. After this call, it is safe to unref the task and clean up the lock set with 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.

new

taskNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> TaskFunction

func: The TaskFunction to use

-> m Task

Returns: A new Task.

MT safe.

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 Task to change the function.

This function will not yet create and start a thread. Use taskStart or taskPause to create and start the GThread.

Before the task can be used, a RecMutex must be configured using the taskSetLock function. This lock will always be acquired while func is called.

pause

taskPause Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: The Task to pause

-> m Bool

Returns: True if the task could be paused.

MT safe.

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.

setEnterCallback

taskSetEnterCallback Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: The Task to use

-> TaskThreadFunc

enterFunc: a TaskThreadFunc

-> m () 

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.

setLeaveCallback

taskSetLeaveCallback Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: The Task to use

-> TaskThreadFunc

leaveFunc: a TaskThreadFunc

-> m () 

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.

setLock

taskSetLock Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: The Task to use

-> RecMutex

mutex: The RecMutex to use

-> m () 

Set the mutex used by the task. The mutex will be acquired before calling the TaskFunction.

This function has to be called before calling taskPause or taskStart.

MT safe.

setPool

taskSetPool Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a, IsTaskPool b) 
=> a

task: a Task

-> b

pool: a TaskPool

-> m () 

Set pool as the new GstTaskPool for task. Any new streaming threads that will be created by task will now use pool.

MT safe.

setState

taskSetState Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: a Task

-> TaskState

state: the new task state

-> m Bool

Returns: True if the state could be changed.

Sets the state of task to state.

The task must have a lock associated with it using taskSetLock when going to GST_TASK_STARTED or GST_TASK_PAUSED or this function will return False.

MT safe.

start

taskStart Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: The Task to start

-> m Bool

Returns: True if the task could be started.

MT safe.

Starts task. The task must have a lock associated with it using taskSetLock or this function will return False.

stop

taskStop Source #

Arguments

:: (HasCallStack, MonadIO m, IsTask a) 
=> a

task: The Task to stop

-> m Bool

Returns: True if the task could be stopped.

MT safe.

Stops task. This method merely schedules the task to stop and will not wait for the task to have completely stopped. Use taskJoin to stop and wait for completion.