Next: GstTrace, Previous: GstTagSetter, Up: Top
Abstraction of GStreamer streaming threads.
<gst-task>
is used by <gst-element>
and <gst-pad>
to
provide the data passing threads in a <gst-pipeline>
.
A <gst-pad>
will typically start a <gst-task>
to push or pull data
to/from the peer pads. Most source elements start a <gst-task>
to push
data. In some cases a demuxer element can start a <gst-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 <gst-pad>
to start/pause/stop
tasks, it might sometimes be needed to create a <gst-task>
manually if it
is not related to a <gst-pad>
.
Before the <gst-task>
can be run, it needs a <g-static-rec-mutex>
that can be set with gst-task-set-lock
.
The task can be started, paused and stopped with gst-task-start
,
gst-task-pause
and gst-task-stop
respectively.
A <gst-task>
will repeadedly call the <gst-task-function>
with the
user data that was provided when creating the task with gst-task-create
.
Before calling the function it will acquire the provided lock.
Stopping a task with gst-task-stop
will not immediatly make sure the task
is not running anymore. Use gst-task-join
to make sure the task is
completely stopped and the thread is stopped.
After creating a <gst-task>
, use gst-object-unref
to free its
resources. This can only be done it the task is not running anymore.
Last reviewed on 2006-02-13 (0.10.4)
This
<gobject>
class defines no properties, other than those defined by its superclasses.
Wait for all tasks to be stopped. This is mainly used internally to ensure proper cleanup of internal datastructures in testsuites.
MT safe.
<gst-task-function>
) (data <gpointer>
) (ret <gst-task>
)Create a new Task that will repeadedly call the provided func with data 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 GstTask to change the function.
- func
- The
<gst-task-function>
to use- data
- User data to pass to func
- ret
- A new
<gst-task>
. MT safe.
<gst-task>
) (ret <gst-task-state>
)Get the current state of the task.
- task
- The
<gst-task>
to query- ret
- The
<gst-task-state>
of the task MT safe.
<gst-task>
) (ret bool
)Joins task. After this call, it is safe to unref the task and clean up the lock set with
gst-task-set-lock
.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.
- task
- The
<gst-task>
to join- ret
- TRUE if the task could be joined. MT safe.
<gst-task>
) (ret bool
)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.
- task
- The
<gst-task>
to pause- ret
- TRUE if the task could be paused. MT safe.
<gst-task>
) (mutex <g-static-rec-mutex*>
)Set the mutex used by the task. The mutex will be acquired before calling the
<gst-task-function>
.This function has to be called before calling
gst-task-pause
orgst-task-start
.MT safe.
- task
- The
<gst-task>
to use- mutex
- The GMutex to use
<gst-task>
) (ret bool
)Starts task. The task must have a lock associated with it using
gst-task-set-lock
or thsi function will return FALSE.
- task
- The
<gst-task>
to start- ret
- TRUE if the task could be started. MT safe.
<gst-task>
) (ret bool
)Stops task. This method merely schedules the task to stop and will not wait for the task to have completely stopped. Use
gst-task-join
to stop and wait for completion.
- task
- The
<gst-task>
to stop- ret
- TRUE if the task could be stopped. MT safe.