[gstreamermm: 84/167] [peper0] Corrected default retval of BaseSrc::start & stop vfuncs to true (neutral)



commit e093624556b9c2c277215eebf2a8fe559bfaae36
Author: Marcin Kolny at Flytronic <marcin kolny flytronic pl>
Date:   Tue Jul 30 13:37:34 2013 +0200

    [peper0] Corrected default retval of BaseSrc::start & stop vfuncs to true (neutral)

 gstreamer/src/basesrc.ccg |  120 +++++++++++++++++++++++++++++++++++++++++++++
 gstreamer/src/basesrc.hg  |    8 ++-
 2 files changed, 126 insertions(+), 2 deletions(-)
---
diff --git a/gstreamer/src/basesrc.ccg b/gstreamer/src/basesrc.ccg
index d8d4f18..eea0ba8 100644
--- a/gstreamer/src/basesrc.ccg
+++ b/gstreamer/src/basesrc.ccg
@@ -203,4 +203,124 @@ FlowReturn Gst::BaseSrc::create_vfunc(guint64 offset, guint size, Glib::RefPtr<G
   return RType();
 }
 
+gboolean BaseSrc_Class::start_vfunc_callback(GstBaseSrc* self)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        return static_cast<int>(obj->start_vfunc());
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The 
original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->start)
+  {
+    gboolean result = (*base->start)(self);
+    return result;
+  }
+
+
+  return true;
+}
+gboolean BaseSrc_Class::stop_vfunc_callback(GstBaseSrc* self)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        return static_cast<int>(obj->stop_vfunc());
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The 
original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->stop)
+  {
+    gboolean result = (*base->stop)(self);
+    return result;
+  }
+
+
+  return true;
+}
+
+bool Gst::BaseSrc::start_vfunc()
+{
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class 
(The original underlying C class).
+  );
+
+  if(base && base->start)
+  {
+    bool result((*base->start)(gobj()));
+    return result;
+  }
+
+  return true;
+}
+bool Gst::BaseSrc::stop_vfunc()
+{
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class 
(The original underlying C class).
+  );
+
+  if(base && base->stop)
+  {
+    bool result((*base->stop)(gobj()));
+    return result;
+  }
+
+  return true;
+}
+
 } // namespace Gst
diff --git a/gstreamer/src/basesrc.hg b/gstreamer/src/basesrc.hg
index 1681b92..a888256 100644
--- a/gstreamer/src/basesrc.hg
+++ b/gstreamer/src/basesrc.hg
@@ -185,11 +185,11 @@ public:
   /** Start processing. Subclasses should open resources and prepare to produce
    * data.
    */
-  _WRAP_VFUNC(bool start(), "start")
+  virtual bool start_vfunc();
 
   /** Stop processing. Subclasses should use this to close resources.
    */
-  _WRAP_VFUNC(bool stop(), "stop")
+  virtual bool stop_vfunc();
 
 #m4 _CONVERSION(`GstBuffer*', `const Glib::RefPtr<Gst::Buffer>&', `Glib::wrap($3, true)')
 #m4 _CONVERSION(`GstClockTime*', `ClockTime&', `*($3)')
@@ -250,10 +250,14 @@ public:
 protected:
 #m4begin
   _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
+  klass->start = &start_vfunc_callback;
+  klass->stop = &stop_vfunc_callback;
   klass->do_seek = &do_seek_vfunc_callback;
   klass->prepare_seek_segment = &prepare_seek_segment_vfunc_callback;
   klass->create = &create_vfunc_callback;
   _SECTION(SECTION_PH_VFUNCS)
+  static gboolean start_vfunc_callback(GstBaseSrc* self);
+  static gboolean stop_vfunc_callback(GstBaseSrc* self);
   static gboolean do_seek_vfunc_callback(GstBaseSrc* self, GstSegment* segment);
   static gboolean prepare_seek_segment_vfunc_callback(GstBaseSrc* self, GstEvent* seek, GstSegment* segment);
   static GstFlowReturn create_vfunc_callback(GstBaseSrc* self, guint64 offset, guint size, GstBuffer** buf);


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