*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifndef __GST_TASK_H__
* A function that will repeatedly be called in the thread created by
* a #GstTask.
*/
-typedef void (*GstTaskFunction) (void *user_data);
+typedef void (*GstTaskFunction) (gpointer user_data);
/* --- standard type macros --- */
#define GST_TYPE_TASK (gst_task_get_type ())
#define GST_TASK_GET_LOCK(task) (GST_TASK_CAST(task)->lock)
/**
- * GstTaskThreadCallbacks:
- * @enter_thread: a thread is entered, this callback is called when the new
- * thread enters its function.
- * @leave_thread: a thread is exiting, this is called when the thread is about
- * to leave its function
+ * GstTaskThreadFunc:
+ * @task: The #GstTask
+ * @thread: The #GThread
+ * @user_data: user data
*
* Custom GstTask thread callback functions that can be installed.
- *
- * Since: 0.10.24
*/
-typedef struct {
- /* manage the lifetime of the thread */
- void (*enter_thread) (GstTask *task, GThread *thread, gpointer user_data);
- void (*leave_thread) (GstTask *task, GThread *thread, gpointer user_data);
- /*< private >*/
- gpointer _gst_reserved[GST_PADDING];
-} GstTaskThreadCallbacks;
+typedef void (*GstTaskThreadFunc) (GstTask *task, GThread *thread, gpointer user_data);
/**
* GstTask:
* @cond: used to pause/resume the task
* @lock: The lock taken when iterating the task function
* @func: the function executed by this task
- * @data: data passed to the task function
+ * @user_data: user_data passed to the task function
+ * @notify: GDestroyNotify for @user_data
* @running: a flag indicating that the task is running
*
* The #GstTask object.
GRecMutex *lock;
GstTaskFunction func;
- gpointer data;
+ gpointer user_data;
+ GDestroyNotify notify;
gboolean running;
gpointer _gst_reserved[GST_PADDING];
};
+GST_API
void gst_task_cleanup_all (void);
+GST_API
GType gst_task_get_type (void);
-GstTask* gst_task_new (GstTaskFunction func, gpointer data);
+GST_API
+GstTask* gst_task_new (GstTaskFunction func,
+ gpointer user_data, GDestroyNotify notify);
+GST_API
void gst_task_set_lock (GstTask *task, GRecMutex *mutex);
+GST_API
GstTaskPool * gst_task_get_pool (GstTask *task);
-void gst_task_set_pool (GstTask *task, GstTaskPool *pool);
-void gst_task_set_thread_callbacks (GstTask *task,
- GstTaskThreadCallbacks *callbacks,
- gpointer user_data,
- GDestroyNotify notify);
+GST_API
+void gst_task_set_pool (GstTask *task, GstTaskPool *pool);
+GST_API
+void gst_task_set_enter_callback (GstTask *task,
+ GstTaskThreadFunc enter_func,
+ gpointer user_data,
+ GDestroyNotify notify);
+GST_API
+void gst_task_set_leave_callback (GstTask *task,
+ GstTaskThreadFunc leave_func,
+ gpointer user_data,
+ GDestroyNotify notify);
+GST_API
GstTaskState gst_task_get_state (GstTask *task);
+
+GST_API
gboolean gst_task_set_state (GstTask *task, GstTaskState state);
+GST_API
gboolean gst_task_start (GstTask *task);
+
+GST_API
gboolean gst_task_stop (GstTask *task);
+
+GST_API
gboolean gst_task_pause (GstTask *task);
+GST_API
gboolean gst_task_join (GstTask *task);
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstTask, gst_object_unref)
+#endif
+
G_END_DECLS
#endif /* __GST_TASK_H__ */