X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgsttask.h;h=f93d4c122848c54f04631264f311b71b5ef09d26;hb=ce43de86902c4e9c8ed4e9682602664cb9bce2ee;hp=02b2e281d6d88796f5086add533cb4919c2d44af;hpb=148bf27ce36a2abf88f431bf83214779db771a64;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gsttask.h b/gst/gsttask.h index 02b2e28..f93d4c1 100644 --- a/gst/gsttask.h +++ b/gst/gsttask.h @@ -16,8 +16,8 @@ * * 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__ @@ -30,12 +30,12 @@ G_BEGIN_DECLS /** * 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 ()) @@ -78,7 +78,7 @@ typedef enum { * * 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 @@ -110,23 +110,14 @@ typedef enum { #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: @@ -134,7 +125,8 @@ typedef struct { * @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. @@ -144,12 +136,13 @@ struct _GstTask { /*< public >*/ /* with LOCK */ GstTaskState state; - GCond *cond; + GCond cond; - GStaticRecMutex *lock; + GRecMutex *lock; GstTaskFunction func; - gpointer data; + gpointer user_data; + GDestroyNotify notify; gboolean running; @@ -171,31 +164,56 @@ struct _GstTaskClass { 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); -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__ */