[gstreamermm] Gst::AudioFilter: don't wrap virtual function manually



commit c1482a3b8cedbce2e49e0e5b7f4ae9473b7612fd
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Sat Apr 23 16:39:11 2016 +0200

    Gst::AudioFilter: don't wrap virtual function manually
    
        * gstreamer/src/audiofilter.{ccg|hg}: setup vfunc method can be
          wrapped using macro, it only requires custom conversion definition.
        * gstreamer/src/gst_vfuncs.defs: fix virtual method definition.
        * tools/m4/convert_gst.m4: add audioinfo conversion definition.

 gstreamer/src/audiofilter.ccg |   60 +----------------------------------------
 gstreamer/src/audiofilter.hg  |   17 +++--------
 gstreamer/src/gst_vfuncs.defs |    2 +-
 tools/m4/convert_gst.m4       |    3 ++
 4 files changed, 10 insertions(+), 72 deletions(-)
---
diff --git a/gstreamer/src/audiofilter.ccg b/gstreamer/src/audiofilter.ccg
index 45b55ca..95f38e3 100644
--- a/gstreamer/src/audiofilter.ccg
+++ b/gstreamer/src/audiofilter.ccg
@@ -1,6 +1,6 @@
 /* gstreamermm - a C++ wrapper for gstreamer
  *
- * Copyright 2008 The gstreamermm Development Team
+ * Copyright 2008-2016 The gstreamermm Development Team
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -21,61 +21,3 @@
 
 _PINCLUDE(gstreamermm/private/basetransform_p.h)
 
-namespace Gst
-{
-
-gboolean AudioFilter_Class::setup_vfunc_callback(GstAudioFilter* self, const GstAudioInfo* info)
-{
-  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.
-    {
-      try // Trap C++ exceptions which would normally be lost because this is a C callback.
-      {
-        Gst::AudioInfo audio_info(info, false);
-
-        // Call the virtual member method, which derived classes might override.
-        return static_cast<int>(obj->setup_vfunc(audio_info));
-      }
-      catch(...)
-      {
-        Glib::exception_handlers_invoke();
-      }
-    }
-  }
-  
-  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->setup)
-    return (*base->setup)(self, info);
-
-
-  typedef gboolean RType;
-  return RType();
-}
-bool Gst::AudioFilter::setup_vfunc(Gst::AudioInfo& info)
-{
-  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->setup)
-    return static_cast<bool>((*base->setup)(gobj(), info.gobj()));
-
-  typedef bool RType;
-  return RType();
-}
-
-} // namespace Gst
diff --git a/gstreamer/src/audiofilter.hg b/gstreamer/src/audiofilter.hg
index 303abc3..976e264 100644
--- a/gstreamer/src/audiofilter.hg
+++ b/gstreamer/src/audiofilter.hg
@@ -1,6 +1,6 @@
 /* gstreamermm - a C++ wrapper for gstreamer
  *
- * Copyright 2008 The gstreamermm Development Team
+ * Copyright 2008-2016 The gstreamermm Development Team
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -18,7 +18,6 @@
  */
 
 #include <gstreamermm/basetransform.h>
-#include <gstreamermm/audioringbuffer.h>
 #include <gstreamermm/audioinfo.h>
 
 _DEFS(gstreamermm,gst)
@@ -40,6 +39,8 @@ namespace Gst
  * Gst::BaseTransform::transform_ip_vfunc() and/or
  * Gst::BaseTransform::transform_vfunc() virtual functions.
  *
+ * Last reviewed on 2016-04-23 (1.8.0).
+ *
  * @ingroup GstBaseClasses
  */
 class AudioFilter : public Gst::BaseTransform
@@ -47,18 +48,10 @@ class AudioFilter : public Gst::BaseTransform
   _CLASS_GOBJECT(AudioFilter, GstAudioFilter, GST_AUDIO_FILTER, Gst::BaseTransform, GstBaseTransform)
 
 public:
+#m4 _CONVERSION(`const GstAudioInfo*', `const Gst::AudioInfo&', `Gst::AudioInfo($3, false)')
   /** Virtual function, called whenever the format changes.
    */
-  virtual bool setup_vfunc(Gst::AudioInfo& info);
-
-protected:
-#m4begin
-  _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
-  klass->setup = &setup_vfunc_callback;
-  _SECTION(SECTION_PH_VFUNCS)
-  static gboolean setup_vfunc_callback(GstAudioFilter* self, const GstAudioInfo* info);
-  _POP()
-#m4end
+  _WRAP_VFUNC(bool setup(const Gst::AudioInfo& info), "setup")
 };
 
 } // namespace Gst
diff --git a/gstreamer/src/gst_vfuncs.defs b/gstreamer/src/gst_vfuncs.defs
index a64b5c7..2625aea 100644
--- a/gstreamer/src/gst_vfuncs.defs
+++ b/gstreamer/src/gst_vfuncs.defs
@@ -28,7 +28,7 @@
   (of-object "GstAudioFilter")
   (return-type "gboolean")
   (parameters
-   '("GstAudioRingBufferSpec*" "format")
+   '("const-GstAudioInfo*" "info")
   )
 )
 
diff --git a/tools/m4/convert_gst.m4 b/tools/m4/convert_gst.m4
index bcc087b..9513b7c 100644
--- a/tools/m4/convert_gst.m4
+++ b/tools/m4/convert_gst.m4
@@ -89,6 +89,9 @@ _CONVERSION(`const Glib::RefPtr<Gst::Allocator>&',`GstAllocator*', `const_cast<G
 _CONVERSION(`Glib::RefPtr<Gst::Allocator>&&',`GstAllocator*',`($3) ? $3.release()->gobj() : nullptr');
 _CONVERSION(`GstAllocator*', `Glib::RefPtr<Gst::Allocator>', `Glib::wrap($3)')
 
+dnl AudioInfo
+_CONVERSION(`const Gst::AudioInfo&', `const GstAudioInfo*', `$3.gobj()')
+
 dnl Buffer
 _CONVERSION(`GstBuffer*',`Glib::RefPtr<Gst::Buffer>',`Glib::wrap($3)')
 _CONVERSION(`GstBuffer*',`const Glib::RefPtr<Gst::Buffer>&',`Glib::wrap($3, true)')


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