gstreamer_core/gst/gsttask.h
changeset 8 4a7fac7dd34a
parent 0 0e761a78d257
child 30 7e817e7e631c
equal deleted inserted replaced
7:71e347f905f2 8:4a7fac7dd34a
    22 
    22 
    23 #ifndef __GST_TASK_H__
    23 #ifndef __GST_TASK_H__
    24 #define __GST_TASK_H__
    24 #define __GST_TASK_H__
    25 
    25 
    26 #include <gst/gstobject.h>
    26 #include <gst/gstobject.h>
       
    27 #include <gst/gsttaskpool.h>
    27 
    28 
    28 G_BEGIN_DECLS
    29 G_BEGIN_DECLS
    29 
    30 
    30 /**
    31 /**
    31  * GstTaskFunction:
    32  * GstTaskFunction:
    32  * @data: user data passed to the function
    33  * @data: user data passed to the function
    33  *
    34  *
    34  * A function that will repeadedly be called in the thread created by
    35  * A function that will repeatedly be called in the thread created by
    35  * a GstTask. 
    36  * a #GstTask.
    36  */
    37  */
    37 typedef void         (*GstTaskFunction)          (void *data);
    38 typedef void         (*GstTaskFunction)          (void *data);
    38 
    39 
    39 /* --- standard type macros --- */
    40 /* --- standard type macros --- */
    40 #define GST_TYPE_TASK                 	(gst_task_get_type ())
    41 #define GST_TYPE_TASK                 	(gst_task_get_type ())
    45 #define GST_TASK_GET_CLASS(task)      	(G_TYPE_INSTANCE_GET_CLASS ((task), GST_TYPE_TASK, GstTaskClass))
    46 #define GST_TASK_GET_CLASS(task)      	(G_TYPE_INSTANCE_GET_CLASS ((task), GST_TYPE_TASK, GstTaskClass))
    46 #define GST_TASK_CAST(task)            	((GstTask*)(task))
    47 #define GST_TASK_CAST(task)            	((GstTask*)(task))
    47 
    48 
    48 typedef struct _GstTask GstTask;
    49 typedef struct _GstTask GstTask;
    49 typedef struct _GstTaskClass GstTaskClass;
    50 typedef struct _GstTaskClass GstTaskClass;
       
    51 typedef struct _GstTaskPrivate GstTaskPrivate;
    50 
    52 
    51 /**
    53 /**
    52  * GstTaskState:
    54  * GstTaskState:
    53  * @GST_TASK_STARTED: the task is started and running
    55  * @GST_TASK_STARTED: the task is started and running
    54  * @GST_TASK_STOPPED:  the task is stopped
    56  * @GST_TASK_STOPPED: the task is stopped
    55  * @GST_TASK_PAUSED: the task is paused
    57  * @GST_TASK_PAUSED: the task is paused
    56  *
    58  *
    57  * The different states a task can be in
    59  * The different states a task can be in
    58  */
    60  */
    59 typedef enum {
    61 typedef enum {
   106  * Get access to the task lock.
   108  * Get access to the task lock.
   107  */
   109  */
   108 #define GST_TASK_GET_LOCK(task)		(GST_TASK_CAST(task)->lock)
   110 #define GST_TASK_GET_LOCK(task)		(GST_TASK_CAST(task)->lock)
   109 
   111 
   110 /**
   112 /**
       
   113  * GstTaskThreadCallbacks:
       
   114  * @enter_thread: a thread is entered, this callback is called when the new
       
   115  *   thread enters its function.
       
   116  * @leave_thread: a thread is exiting, this is called when the thread is about
       
   117  *   to leave its function
       
   118  *
       
   119  * Custom GstTask thread callback functions that can be installed. 
       
   120  *
       
   121  * Since: 0.10.24
       
   122  */
       
   123 typedef struct {
       
   124   /* manage the lifetime of the thread */
       
   125   void      (*enter_thread)     (GstTask *task, GThread *thread, gpointer user_data);
       
   126   void      (*leave_thread)     (GstTask *task, GThread *thread, gpointer user_data);
       
   127   /*< private >*/
       
   128   gpointer     _gst_reserved[GST_PADDING];
       
   129 } GstTaskThreadCallbacks;
       
   130 
       
   131 /**
   111  * GstTask:
   132  * GstTask:
   112  * @state: the state of the task
   133  * @state: the state of the task
   113  * @cond: used to pause/resume the task
   134  * @cond: used to pause/resume the task
   114  * @lock: The lock taken when iterating the taskfunction
   135  * @lock: The lock taken when iterating the task function
   115  * @func: the function executed by this task
   136  * @func: the function executed by this task
   116  * @data: data passed to the task function
   137  * @data: data passed to the task function
   117  * @running: a flag indicating that the task is running.
   138  * @running: a flag indicating that the task is running
   118  *
   139  *
   119  * The #GstTask object.
   140  * The #GstTask object.
   120  */
   141  */
   121 struct _GstTask {
   142 struct _GstTask {
   122   GstObject      object;
   143   GstObject      object;
   136   union {
   157   union {
   137     struct {
   158     struct {
   138       /* thread this task is currently running in */
   159       /* thread this task is currently running in */
   139       GThread  *thread;
   160       GThread  *thread;
   140     } ABI;
   161     } ABI;
   141     /* adding + 0 to mark ABI change to be undone later */
   162     gpointer _gst_reserved[GST_PADDING - 1];
   142     gpointer _gst_reserved[GST_PADDING + 0];
       
   143   } abidata;
   163   } abidata;
   144 
   164 
       
   165   GstTaskPrivate *priv;
   145 };
   166 };
   146 
   167 
   147 struct _GstTaskClass {
   168 struct _GstTaskClass {
   148   GstObjectClass parent_class;
   169   GstObjectClass parent_class;
   149 
   170 
   150   /*< private >*/
   171   /*< private >*/
   151   GThreadPool *pool;
   172   GstTaskPool *pool;
   152 
   173 
   153   /*< private >*/
   174   /*< private >*/
   154   gpointer _gst_reserved[GST_PADDING];
   175   gpointer _gst_reserved[GST_PADDING];
   155 };
   176 };
   156 #ifdef __SYMBIAN32__
   177 #ifdef __SYMBIAN32__
   178 void		gst_task_set_lock	(GstTask *task, GStaticRecMutex *mutex);
   199 void		gst_task_set_lock	(GstTask *task, GStaticRecMutex *mutex);
   179 #ifdef __SYMBIAN32__
   200 #ifdef __SYMBIAN32__
   180 IMPORT_C
   201 IMPORT_C
   181 #endif
   202 #endif
   182 
   203 
       
   204 void		gst_task_set_priority	(GstTask *task, GThreadPriority priority);
       
   205 #ifdef __SYMBIAN32__
       
   206 IMPORT_C
       
   207 #endif
       
   208 
       
   209 
       
   210 GstTaskPool *   gst_task_get_pool       (GstTask *task);
       
   211 #ifdef __SYMBIAN32__
       
   212 IMPORT_C
       
   213 #endif
       
   214 
       
   215 void            gst_task_set_pool       (GstTask *task, GstTaskPool *pool);
       
   216 #ifdef __SYMBIAN32__
       
   217 IMPORT_C
       
   218 #endif
       
   219 
       
   220 
       
   221 void            gst_task_set_thread_callbacks  (GstTask *task,
       
   222                                                 GstTaskThreadCallbacks *callbacks,
       
   223 						gpointer user_data,
       
   224 						GDestroyNotify notify);
       
   225 #ifdef __SYMBIAN32__
       
   226 IMPORT_C
       
   227 #endif
       
   228 
   183 
   229 
   184 GstTaskState	gst_task_get_state	(GstTask *task);
   230 GstTaskState	gst_task_get_state	(GstTask *task);
   185 #ifdef __SYMBIAN32__
   231 #ifdef __SYMBIAN32__
   186 IMPORT_C
   232 IMPORT_C
   187 #endif
   233 #endif
   188 
   234 
       
   235 gboolean        gst_task_set_state      (GstTask *task, GstTaskState state);
       
   236 #ifdef __SYMBIAN32__
       
   237 IMPORT_C
       
   238 #endif
       
   239 
   189 
   240 
   190 gboolean	gst_task_start		(GstTask *task);
   241 gboolean	gst_task_start		(GstTask *task);
   191 #ifdef __SYMBIAN32__
   242 #ifdef __SYMBIAN32__
   192 IMPORT_C
   243 IMPORT_C
   193 #endif
   244 #endif
   206 gboolean	gst_task_join		(GstTask *task);
   257 gboolean	gst_task_join		(GstTask *task);
   207 
   258 
   208 G_END_DECLS
   259 G_END_DECLS
   209 
   260 
   210 #endif /* __GST_TASK_H__ */
   261 #endif /* __GST_TASK_H__ */
   211