Class: Gst::Task

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#add_control_binding, check_uniqueness, #control_bindings_disabled=, #control_rate, #control_rate=, default_deep_notify, #default_error, #get_control_binding, #get_g_value_array, #get_value, #get_value_array, #has_active_control_bindings, #has_ancestor, #has_as_ancestor, #has_as_parent, #name, #name=, #parent, #parent=, #path_string, #ref, ref_sink, #remove_control_binding, replace, #set_control_binding_disabled, #suggest_next_sync, #sync_values, #unparent, #unref

Constructor Details

#initialize(func, user_data, notify) ⇒ Gst::Task

Create a new Task that will repeatedly call the provided func
with user_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 Gst::Task to change the function.

This function will not yet create and start a thread. Use gst_task_start() or
gst_task_pause() to create and start the GThread.

Before the task can be used, a GRec::Mutex must be configured using the
gst_task_set_lock() function. This lock will always be acquired while
func is called.
MT safe.

Parameters:

  • func (Gst::TaskFunction)

    The Gst::TaskFunction to use

  • user_data (GObject)

    User data to pass to func

  • notify (GLib::DestroyNotify)

    the function to call when user_data is no longer needed.

Class Method Details

.cleanup_allnil

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.

Returns:

  • (nil)

Instance Method Details

#joinBoolean

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.
MT safe.

Returns:

  • (Boolean)

    true if the task could be joined.

#lock=(mutex) ⇒ nil

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

This function has to be called before calling gst_task_pause() or
gst_task_start().

MT safe.

Parameters:

  • mutex (GLib::RecMutex)

    The GRec::Mutex to use

Returns:

  • (nil)

#pauseBoolean

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.
MT safe.

Returns:

  • (Boolean)

    true if the task could be paused.

#poolGst::TaskPool

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

MT safe.
after usage.

Returns:

  • (Gst::TaskPool)

    the Gst::TaskPool used by task. gst_object_unref()

#pool=(pool) ⇒ nil

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

MT safe.

Parameters:

Returns:

  • (nil)

#resumeBoolean

Resume task in case it was paused. If the task was stopped, it will
remain in that state and this function will return false.
MT safe.

Returns:

  • (Boolean)

    true if the task could be resumed.

#set_enter_callback(enter_func, user_data, notify) ⇒ nil

Call enter_func when the task function of task is entered. user_data will
be passed to enter_func and notify will be called when user_data is no
longer referenced.

Parameters:

  • enter_func (Gst::TaskThreadFunc)

    a Gst::TaskThreadFunc

  • user_data (GObject)

    user data passed to enter_func

  • notify (GLib::DestroyNotify)

    called when user_data is no longer referenced

Returns:

  • (nil)

#set_leave_callback(leave_func, user_data, notify) ⇒ nil

Call leave_func when the task function of task is left. user_data will
be passed to leave_func and notify will be called when user_data is no
longer referenced.

Parameters:

  • leave_func (Gst::TaskThreadFunc)

    a Gst::TaskThreadFunc

  • user_data (GObject)

    user data passed to leave_func

  • notify (GLib::DestroyNotify)

    called when user_data is no longer referenced

Returns:

  • (nil)

#startBoolean

Starts task. The task must have a lock associated with it using
gst_task_set_lock() or this function will return false.
MT safe.

Returns:

  • (Boolean)

    true if the task could be started.

#stateGst::TaskState

Get the current state of the task.
MT safe.

Returns:

#state=(state) ⇒ Boolean

Sets the state of task to state.

The task must have a lock associated with it using
gst_task_set_lock() when going to GST_TASK_STARTED or GST_TASK_PAUSED or
this function will return false.

MT safe.

Parameters:

Returns:

  • (Boolean)

    true if the state could be changed.

#stopBoolean

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.
MT safe.

Returns:

  • (Boolean)

    true if the task could be stopped.