[gstreamermm] Task: Wrapped new 0.10.24 functions.



commit c3b00148c499b78841d44529a2edc491251ea193
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Wed Aug 5 20:32:11 2009 -0400

    	Task: Wrapped new 0.10.24 functions.
    
    	* gstreamer/src/task.ccg:
    	* gstreamer/src/task.hg: Re-ordered method declarations as in the C
    	API.  Added new 0.10.24 methods.
    	* tools/m4/convert_gst.m4: Added GstTaskPool and GThreadPriority
    	conversions.

 ChangeLog               |   10 ++++++
 gstreamer/src/task.ccg  |   74 +++++++++++++++++++++++++++++++++++++++++++++++
 gstreamer/src/task.hg   |   47 ++++++++++++++++++++++++++++--
 tools/m4/convert_gst.m4 |    9 ++++++
 4 files changed, 137 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e89a576..451a156 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-08-05  José Alburquerque  <jaalburqu svn gnome org>
+
+	Task: Wrapped new 0.10.24 functions.
+
+	* gstreamer/src/task.ccg:
+	* gstreamer/src/task.hg: Re-ordered method declarations as in the C
+	API.  Added new 0.10.24 methods.
+	* tools/m4/convert_gst.m4: Added GstTaskPool and GThreadPriority
+	conversions.
+
 2009-08-04  José Alburquerque  <jaalburqu svn gnome org>
 
 	General API: Use actual slot instead of a copy where possible.
diff --git a/gstreamer/src/task.ccg b/gstreamer/src/task.ccg
index 7030ecc..8c56baa 100644
--- a/gstreamer/src/task.ccg
+++ b/gstreamer/src/task.ccg
@@ -18,8 +18,17 @@
  */
 
 #include <gst/gstenumtypes.h>
+#include <gstreamermm/taskpool.h>
 _PINCLUDE(gstreamermm/private/object_p.h)
 
+// Used in set_thread_slots() method to set the slots.
+struct TaskThreadCallbacks
+{
+  GstTaskThreadCallbacks gst_task_thread_callbacks;
+  Gst::Task::SlotEnter* slot_enter;
+  Gst::Task::SlotLeave* slot_leave;
+};
+
 static void Task_Task_gstreamermm_callback(void* data)
 {
   Gst::Task::SlotTask* the_slot = static_cast<Gst::Task::SlotTask*>(data);
@@ -38,6 +47,52 @@ static void Task_Task_gstreamermm_callback(void* data)
   #endif //GLIBMM_EXCEPTIONS_ENABLED
 }
 
+static void Task_Enter_gstreamermm_callback(GstTask* task, GThread* thread, gpointer user_data)
+{
+  TaskThreadCallbacks* callbacks = static_cast<TaskThreadCallbacks*>(user_data);
+  Gst::Task::SlotEnter* the_slot = callbacks->slot_enter;
+
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  try
+  {
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+    (*the_slot)(Glib::wrap(task, true), Glib::wrap(thread));
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  }
+  catch(...)
+  {
+    Glib::exception_handlers_invoke();
+  }
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+}
+
+static void Task_Leave_gstreamermm_callback(GstTask *task, GThread *thread, gpointer user_data)
+{
+  TaskThreadCallbacks* callbacks = static_cast<TaskThreadCallbacks*>(user_data);
+  Gst::Task::SlotLeave* the_slot = callbacks->slot_leave;
+
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  try
+  {
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+    (*the_slot)(Glib::wrap(task, true), Glib::wrap(thread));
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  }
+  catch(...)
+  {
+    Glib::exception_handlers_invoke();
+  }
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+}
+
+static void Task_Callbacks_gstreamermm_callback_destroy(void* data)
+{
+  TaskThreadCallbacks* callbacks = static_cast<TaskThreadCallbacks*>(data);
+  delete callbacks->slot_enter;
+  delete callbacks->slot_leave;
+  delete callbacks;
+}
+
 namespace Gst
 {
 
@@ -70,6 +125,25 @@ Task::Task(const SlotTask& task_slot)
   gobj()->data = &slot;
 }
 
+void Task::set_thread_slots(const SlotEnter& enter_slot,
+  const SlotLeave& leave_slot)
+{
+  TaskThreadCallbacks* callbacks = new TaskThreadCallbacks;
+
+  callbacks->gst_task_thread_callbacks.enter_thread =
+    &Task_Enter_gstreamermm_callback;
+
+  callbacks->gst_task_thread_callbacks.leave_thread =
+    &Task_Leave_gstreamermm_callback;
+
+  callbacks->slot_enter = new SlotEnter(enter_slot);
+  callbacks->slot_leave = new SlotLeave(leave_slot);
+
+  gst_task_set_thread_callbacks(gobj(),
+    reinterpret_cast<GstTaskThreadCallbacks*>(callbacks), callbacks,
+    &Task_Callbacks_gstreamermm_callback_destroy);
+}
+
 Task::~Task()
 {
   // Delete task's slot upon destruction
diff --git a/gstreamer/src/task.hg b/gstreamer/src/task.hg
index bca0517..69f1c50 100644
--- a/gstreamer/src/task.hg
+++ b/gstreamer/src/task.hg
@@ -27,6 +27,8 @@ namespace Gst
 
 _WRAP_ENUM(TaskState, GstTaskState)
 
+class TaskPool;
+
 /** Gst::Task - Abstraction of GStreamer streaming threads.
  * Gst::Task is used by Gst::Element and Gst::Pad to provide the data passing
  * threads in a Gst::Pipeline.
@@ -69,6 +71,20 @@ public:
    */
   typedef sigc::slot<void> SlotTask;
 
+  /** For example,
+   * void on_enter(const Glib::RefPtr<Gst::Task>& task, Glib::Thread& thread);
+   * A thread is entered, this slot is called when the new thread enters its
+   * function.
+   */
+  typedef sigc::slot<void, const Glib::RefPtr<Gst::Task>&, Glib::Thread*> SlotEnter;
+
+  /** For example,
+   * void on_leave(const Glib::RefPtr<Gst::Task>& task, Glib::Thread& thread);
+   * A thread is exiting, this is called when the thread is about to leave its
+   * function.
+   */
+    typedef sigc::slot<void, const Glib::RefPtr<Gst::Task>&, Glib::Thread*> SlotLeave;
+
 protected:
   Task(const SlotTask& task_slot);
 
@@ -84,13 +100,38 @@ public:
    */
   _WRAP_CREATE(const SlotTask& task_slot)
 
-  _WRAP_METHOD(static void cleanup_all(), gst_task_cleanup_all)
+  _WRAP_METHOD(void set_lock(Glib::StaticRecMutex& mutex), gst_task_set_lock)
+  _WRAP_METHOD(void set_priority(Glib::ThreadPriority priority), gst_task_set_priority)
+  _WRAP_METHOD(void set_pool(const Glib::RefPtr<Gst::TaskPool>& pool), gst_task_set_pool)
+  _WRAP_METHOD(Glib::RefPtr<Gst::TaskPool> get_pool(), gst_task_get_pool)
+  _WRAP_METHOD(Glib::RefPtr<const Gst::TaskPool> get_pool() const, gst_task_get_pool)
+
+  /** Set slots which will be executed when a new thread is needed, the thread
+   * function is entered and left and when the thread is joined.
+   *
+   * By default a thread for task will be created from a default thread pool.
+   *
+   * Objects can use custom Glib::Thread or can perform additional
+   * configuration of the threads (such as changing the thread priority) by
+   * installing slot.
+   *
+   * MT safe.
+   *
+   * @param enter_slot A SlotEnter slot.
+   * @param leave_slot A SlotLeave slot.
+   *
+   * Since 0.10.24.
+   */
+  void set_thread_slots(const SlotEnter& enter_slot, const SlotLeave& leave_slot);
+  _IGNORE(gst_task_set_thread_callbacks)
+
   _WRAP_METHOD(TaskState get_state() const, gst_task_get_state)
-  _WRAP_METHOD(bool join(), gst_task_join)
+  _WRAP_METHOD(void set_state(Gst::TaskState state), gst_task_set_state)
   _WRAP_METHOD(bool pause(), gst_task_pause)
-  _WRAP_METHOD(void set_lock(Glib::StaticRecMutex& mutex), gst_task_set_lock)
   _WRAP_METHOD(bool start(), gst_task_start)
   _WRAP_METHOD(bool stop(), gst_task_stop)
+  _WRAP_METHOD(bool join(), gst_task_join)
+  _WRAP_METHOD(static void cleanup_all(), gst_task_cleanup_all)
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 private:
diff --git a/tools/m4/convert_gst.m4 b/tools/m4/convert_gst.m4
index bf700db..99ea2b0 100644
--- a/tools/m4/convert_gst.m4
+++ b/tools/m4/convert_gst.m4
@@ -36,6 +36,10 @@ _CONV_ENUM(Gst,TaskState)
 _CONV_ENUM(Gst,TunerChannelFlags)
 _CONV_ENUM(Gst,URIType)
 
+#Glibmm Enums
+_CONV_GLIB_ENUM(ThreadPriority)
+
+
 ############### gstreamermm Class Conversions ######################
 
 #Buffer
@@ -162,6 +166,11 @@ _CONVERSION(`GstTagList*',`Gst::TagList',`Glib::wrap($3, 0)')
 _CONVERSION(`Gst::TagList&',`GstTagList*',`$3.gobj()')
 _CONVERSION(`Gst::TagList',`GstTagList*',`$3.gobj()')
 
+#TaskPool
+_CONVERSION(`const Glib::RefPtr<Gst::TaskPool>&',`GstTaskPool*', `Glib::unwrap($3)')
+_CONVERSION(`GstTaskPool*',`Glib::RefPtr<Gst::TaskPool>',`Glib::wrap($3)')
+_CONVERSION(`GstTaskPool*',`Glib::RefPtr<const Gst::TaskPool>',`Glib::wrap($3)')
+
 #TypeFind
 _CONVERSION(`Gst::TypeFind&',`GstTypeFind*',`$3.gobj()')
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]