gstreamer_core/gst/gsttask.h
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    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>
       
    28 
    27 
    29 G_BEGIN_DECLS
    28 G_BEGIN_DECLS
    30 
    29 
    31 /**
    30 /**
    32  * GstTaskFunction:
    31  * GstTaskFunction:
    33  * @data: user data passed to the function
    32  * @data: user data passed to the function
    34  *
    33  *
    35  * A function that will repeatedly be called in the thread created by
    34  * A function that will repeadedly be called in the thread created by
    36  * a #GstTask.
    35  * a GstTask. 
    37  */
    36  */
    38 typedef void         (*GstTaskFunction)          (void *data);
    37 typedef void         (*GstTaskFunction)          (void *data);
    39 
    38 
    40 /* --- standard type macros --- */
    39 /* --- standard type macros --- */
    41 #define GST_TYPE_TASK                 	(gst_task_get_type ())
    40 #define GST_TYPE_TASK                 	(gst_task_get_type ())
    46 #define GST_TASK_GET_CLASS(task)      	(G_TYPE_INSTANCE_GET_CLASS ((task), GST_TYPE_TASK, GstTaskClass))
    45 #define GST_TASK_GET_CLASS(task)      	(G_TYPE_INSTANCE_GET_CLASS ((task), GST_TYPE_TASK, GstTaskClass))
    47 #define GST_TASK_CAST(task)            	((GstTask*)(task))
    46 #define GST_TASK_CAST(task)            	((GstTask*)(task))
    48 
    47 
    49 typedef struct _GstTask GstTask;
    48 typedef struct _GstTask GstTask;
    50 typedef struct _GstTaskClass GstTaskClass;
    49 typedef struct _GstTaskClass GstTaskClass;
    51 typedef struct _GstTaskPrivate GstTaskPrivate;
       
    52 
    50 
    53 /**
    51 /**
    54  * GstTaskState:
    52  * GstTaskState:
    55  * @GST_TASK_STARTED: the task is started and running
    53  * @GST_TASK_STARTED: the task is started and running
    56  * @GST_TASK_STOPPED: the task is stopped
    54  * @GST_TASK_STOPPED:  the task is stopped
    57  * @GST_TASK_PAUSED: the task is paused
    55  * @GST_TASK_PAUSED: the task is paused
    58  *
    56  *
    59  * The different states a task can be in
    57  * The different states a task can be in
    60  */
    58  */
    61 typedef enum {
    59 typedef enum {
   108  * Get access to the task lock.
   106  * Get access to the task lock.
   109  */
   107  */
   110 #define GST_TASK_GET_LOCK(task)		(GST_TASK_CAST(task)->lock)
   108 #define GST_TASK_GET_LOCK(task)		(GST_TASK_CAST(task)->lock)
   111 
   109 
   112 /**
   110 /**
   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 /**
       
   132  * GstTask:
   111  * GstTask:
   133  * @state: the state of the task
   112  * @state: the state of the task
   134  * @cond: used to pause/resume the task
   113  * @cond: used to pause/resume the task
   135  * @lock: The lock taken when iterating the task function
   114  * @lock: The lock taken when iterating the taskfunction
   136  * @func: the function executed by this task
   115  * @func: the function executed by this task
   137  * @data: data passed to the task function
   116  * @data: data passed to the task function
   138  * @running: a flag indicating that the task is running
   117  * @running: a flag indicating that the task is running.
   139  *
   118  *
   140  * The #GstTask object.
   119  * The #GstTask object.
   141  */
   120  */
   142 struct _GstTask {
   121 struct _GstTask {
   143   GstObject      object;
   122   GstObject      object;
   157   union {
   136   union {
   158     struct {
   137     struct {
   159       /* thread this task is currently running in */
   138       /* thread this task is currently running in */
   160       GThread  *thread;
   139       GThread  *thread;
   161     } ABI;
   140     } ABI;
   162     gpointer _gst_reserved[GST_PADDING - 1];
   141     /* adding + 0 to mark ABI change to be undone later */
       
   142     gpointer _gst_reserved[GST_PADDING + 0];
   163   } abidata;
   143   } abidata;
   164 
   144 
   165   GstTaskPrivate *priv;
       
   166 };
   145 };
   167 
   146 
   168 struct _GstTaskClass {
   147 struct _GstTaskClass {
   169   GstObjectClass parent_class;
   148   GstObjectClass parent_class;
   170 
   149 
   171   /*< private >*/
   150   /*< private >*/
   172   GstTaskPool *pool;
   151   GThreadPool *pool;
   173 
   152 
   174   /*< private >*/
   153   /*< private >*/
   175   gpointer _gst_reserved[GST_PADDING];
   154   gpointer _gst_reserved[GST_PADDING];
   176 };
   155 };
   177 #ifdef __SYMBIAN32__
   156 #ifdef __SYMBIAN32__
   199 void		gst_task_set_lock	(GstTask *task, GStaticRecMutex *mutex);
   178 void		gst_task_set_lock	(GstTask *task, GStaticRecMutex *mutex);
   200 #ifdef __SYMBIAN32__
   179 #ifdef __SYMBIAN32__
   201 IMPORT_C
   180 IMPORT_C
   202 #endif
   181 #endif
   203 
   182 
   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 
       
   229 
   183 
   230 GstTaskState	gst_task_get_state	(GstTask *task);
   184 GstTaskState	gst_task_get_state	(GstTask *task);
   231 #ifdef __SYMBIAN32__
   185 #ifdef __SYMBIAN32__
   232 IMPORT_C
   186 IMPORT_C
   233 #endif
   187 #endif
   234 
   188 
   235 gboolean        gst_task_set_state      (GstTask *task, GstTaskState state);
       
   236 #ifdef __SYMBIAN32__
       
   237 IMPORT_C
       
   238 #endif
       
   239 
       
   240 
   189 
   241 gboolean	gst_task_start		(GstTask *task);
   190 gboolean	gst_task_start		(GstTask *task);
   242 #ifdef __SYMBIAN32__
   191 #ifdef __SYMBIAN32__
   243 IMPORT_C
   192 IMPORT_C
   244 #endif
   193 #endif
   257 gboolean	gst_task_join		(GstTask *task);
   206 gboolean	gst_task_join		(GstTask *task);
   258 
   207 
   259 G_END_DECLS
   208 G_END_DECLS
   260 
   209 
   261 #endif /* __GST_TASK_H__ */
   210 #endif /* __GST_TASK_H__ */
       
   211