*
* 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__
/**
* GstTaskFunction:
- * @data: user data passed to the function
+ * @user_data: user data passed to the function
*
* A function that will repeatedly be called in the thread created by
* a #GstTask.
*/
-typedef void (*GstTaskFunction) (void *data);
+typedef void (*GstTaskFunction) (gpointer user_data);
/* --- standard type macros --- */
#define GST_TYPE_TASK (gst_task_get_type ())
*
* Get access to the cond of the task.
*/
-#define GST_TASK_GET_COND(task) (GST_TASK_CAST(task)->cond)
+#define GST_TASK_GET_COND(task) (&GST_TASK_CAST(task)->cond)
/**
* GST_TASK_WAIT:
* @task: Task to wait for
#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
+ * Custom GstTask thread callback functions that can be installed.
*/
-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.
/*< public >*/ /* with LOCK */
GstTaskState state;
- GCond *cond;
+ GCond cond;
- GStaticRecMutex *lock;
+ 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_create (GstTaskFunction func, gpointer data);
-void gst_task_set_lock (GstTask *task, GStaticRecMutex *mutex);
-void gst_task_set_priority (GstTask *task, GThreadPriority priority);
+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__ */