gsttaskpool.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* GStreamer
  2. * Copyright (C) <2009> Wim Taymans <[email protected]>
  3. *
  4. * gsttaskpool.h: Pool for creating streaming threads
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  19. * Boston, MA 02110-1301, USA.
  20. */
  21. #ifndef __GST_TASK_POOL_H__
  22. #define __GST_TASK_POOL_H__
  23. #include <gst/gstobject.h>
  24. G_BEGIN_DECLS
  25. /* --- standard type macros --- */
  26. #define GST_TYPE_TASK_POOL (gst_task_pool_get_type ())
  27. #define GST_TASK_POOL(pool) (G_TYPE_CHECK_INSTANCE_CAST ((pool), GST_TYPE_TASK_POOL, GstTaskPool))
  28. #define GST_IS_TASK_POOL(pool) (G_TYPE_CHECK_INSTANCE_TYPE ((pool), GST_TYPE_TASK_POOL))
  29. #define GST_TASK_POOL_CLASS(pclass) (G_TYPE_CHECK_CLASS_CAST ((pclass), GST_TYPE_TASK_POOL, GstTaskPoolClass))
  30. #define GST_IS_TASK_POOL_CLASS(pclass) (G_TYPE_CHECK_CLASS_TYPE ((pclass), GST_TYPE_TASK_POOL))
  31. #define GST_TASK_POOL_GET_CLASS(pool) (G_TYPE_INSTANCE_GET_CLASS ((pool), GST_TYPE_TASK_POOL, GstTaskPoolClass))
  32. #define GST_TASK_POOL_CAST(pool) ((GstTaskPool*)(pool))
  33. typedef struct _GstTaskPool GstTaskPool;
  34. typedef struct _GstTaskPoolClass GstTaskPoolClass;
  35. /**
  36. * GstTaskPoolFunction:
  37. * @user_data: user data for the task function
  38. *
  39. * Task function, see gst_task_pool_push().
  40. */
  41. typedef void (*GstTaskPoolFunction) (void *user_data);
  42. /**
  43. * GstTaskPool:
  44. *
  45. * The #GstTaskPool object.
  46. */
  47. struct _GstTaskPool {
  48. GstObject object;
  49. /*< private >*/
  50. GThreadPool *pool;
  51. gpointer _gst_reserved[GST_PADDING];
  52. };
  53. /**
  54. * GstTaskPoolClass:
  55. * @parent_class: the parent class structure
  56. * @prepare: prepare the threadpool
  57. * @cleanup: make sure all threads are stopped
  58. * @push: start a new thread
  59. * @join: join a thread
  60. *
  61. * The #GstTaskPoolClass object.
  62. */
  63. struct _GstTaskPoolClass {
  64. GstObjectClass parent_class;
  65. /*< public >*/
  66. void (*prepare) (GstTaskPool *pool, GError **error);
  67. void (*cleanup) (GstTaskPool *pool);
  68. gpointer (*push) (GstTaskPool *pool, GstTaskPoolFunction func,
  69. gpointer user_data, GError **error);
  70. void (*join) (GstTaskPool *pool, gpointer id);
  71. /*< private >*/
  72. gpointer _gst_reserved[GST_PADDING];
  73. };
  74. GType gst_task_pool_get_type (void);
  75. GstTaskPool * gst_task_pool_new (void);
  76. void gst_task_pool_prepare (GstTaskPool *pool, GError **error);
  77. gpointer gst_task_pool_push (GstTaskPool *pool, GstTaskPoolFunction func,
  78. gpointer user_data, GError **error);
  79. void gst_task_pool_join (GstTaskPool *pool, gpointer id);
  80. void gst_task_pool_cleanup (GstTaskPool *pool);
  81. G_END_DECLS
  82. #endif /* __GST_TASK_POOL_H__ */