gnomemm r1977 - gstreamermm/trunk/gstreamer/src



Author: jaalburqu
Date: Thu Jan  8 23:27:11 2009
New Revision: 1977
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1977&view=rev

Log:
2009-01-08  Josà Alburquerque  <jaalburqu svn gnome org>

	* gstreamer/src/mixer.ccg:
	* gstreamer/src/mixer.hg:
	* gstreamer/src/gst_vfuncs.defs: Added vfuncs.  Handwrote the
	get_volume_vfunc() one (adapted from gtkmm) because the C++ version
	returns the array (Glib::ArrayHandle<int>) instead of requiring a
	pointer in which to store the result.

Modified:
   gstreamermm/trunk/gstreamer/src/gst_vfuncs.defs
   gstreamermm/trunk/gstreamer/src/mixer.ccg
   gstreamermm/trunk/gstreamer/src/mixer.hg

Modified: gstreamermm/trunk/gstreamer/src/gst_vfuncs.defs
==============================================================================
--- gstreamermm/trunk/gstreamer/src/gst_vfuncs.defs	(original)
+++ gstreamermm/trunk/gstreamer/src/gst_vfuncs.defs	Thu Jan  8 23:27:11 2009
@@ -543,7 +543,67 @@
   )
 )
 
-; GstColorBalance
+; GstMixer
+
+(define-vfunc list_tracks
+  (of-object "GstMixer")
+  (return-type "const-GList*")
+)
+
+(define-vfunc get_volume
+  (of-object "GstMixer")
+  (return-type "void")
+  (parameters
+   '("GstMixerTrack*" "track")
+   '("gint*" "volumes")
+  )
+)
+
+(define-vfunc set_volume
+  (of-object "GstMixer")
+  (return-type "void")
+  (parameters
+   '("GstMixerTrack*" "track")
+   '("gint*" "volumes")
+  )
+)
+
+(define-vfunc set_mute
+  (of-object "GstMixer")
+  (return-type "void")
+  (parameters
+   '("GstMixerTrack*" "track")
+   '("gboolean" "mute")
+  )
+)
+
+(define-vfunc set_record
+  (of-object "GstMixer")
+  (return-type "void")
+  (parameters
+   '("GstMixerTrack*" "track")
+   '("gboolean" "record")
+  )
+)
+
+(define-vfunc set_option
+  (of-object "GstMixer")
+  (return-type "void")
+  (parameters
+   '("GstMixerOptions*" "opts")
+   '("gchar*" "value")
+  )
+)
+
+(define-vfunc get_option
+  (of-object "GstMixer")
+  (return-type "const-gchar*")
+  (parameters
+   '("GstMixerOptions*" "opts")
+  )
+)
+
+; GstNavigation
 
 (define-vfunc send_event
   (of-object "GstNavigation")

Modified: gstreamermm/trunk/gstreamer/src/mixer.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/mixer.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/mixer.ccg	Thu Jan  8 23:27:11 2009
@@ -21,10 +21,9 @@
 
  #include <gst/interfaces/mixer.h>
  #include <gstreamermm/mixeroptions.h>
- #include <gstreamermm/mixertrack.h>
 
- namespace Gst
- {
+namespace Gst
+{
 
 Glib::ArrayHandle<int> Mixer::get_volume(const Glib::RefPtr<Gst::MixerTrack>& track)
 {
@@ -37,4 +36,73 @@
     Glib::OWNERSHIP_DEEP);
 }
 
+#ifdef GLIBMM_VFUNCS_ENABLED
+// This vfunc wrapper is manually written, because we want the C++ vfunc to
+// return the result instead of passing in a pointer in which to store it.
+
+void Mixer_Class::get_volume_vfunc_callback(GstMixer* self, GstMixerTrack* track, gint* volumes)
+{
+  CppObjectType *const obj = dynamic_cast<CppObjectType*>(
+      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 && obj->is_derived_())
+  {
+    #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.
+      Glib::ArrayHandle<int> result = obj->get_volume_vfunc(Glib::wrap(track, true));
+      const int* result_data = result.data();
+      for (int i = 0; i < result.size(); i++)
+      {
+        volumes[i] = result_data[i];
+      }
+    #ifdef GLIBMM_EXCEPTIONS_ENABLED
+    }
+    catch(...)
+    {
+      Glib::exception_handlers_invoke();
+    }
+    #endif //GLIBMM_EXCEPTIONS_ENABLED
+  }
+  else
+  {
+    BaseClassType *const base = static_cast<BaseClassType*>(
+        g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
+g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
+)    );
+
+    // Call the original underlying C function:
+    if(base && base->get_volume)
+      return (*base->get_volume)(self, track, volumes);
+  }
+}
+
+Glib::ArrayHandle<int> Gst::Mixer::get_volume_vfunc(const Glib::RefPtr<Gst::MixerTrack>& track)
+{
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
+g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
+)  );
+
+  if(base && base->get_volume)
+  {
+    const guint32 num_channels = track->get_num_channels();
+    int* volumes = new int[num_channels];
+    (*base->get_volume)(const_cast<GstMixer*>(gobj()),const_cast<GstMixerTrack*>((track)->gobj()), volumes);
+    return Glib::ArrayHandle<int>(volumes, num_channels, Glib::OWNERSHIP_DEEP);
+  }
+
+  typedef Glib::ArrayHandle<int> RType;
+  return RType(0, 0, Glib::OWNERSHIP_DEEP);
+}
+#endif //GLIBMM_VFUNCS_ENABLED
+
+
 } // namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/mixer.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/mixer.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/mixer.hg	Thu Jan  8 23:27:11 2009
@@ -19,6 +19,8 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <gst/interfaces/mixeroptions.h>
+#include <gstreamermm/mixertrack.h>
 #include <glibmm/interface.h>
 
 _DEFS(gstreamermm,gst)
@@ -41,8 +43,8 @@
   _CLASS_INTERFACE(Mixer, GstMixer, GST_MIXER, GstMixerClass)
 
 public:
-#m4 _CONVERSION(`const GList*', `Glib::ListHandle< Glib::RefPtr<MixerTrack> >', `$2(const_cast<GList*>($3), Glib::OWNERSHIP_NONE)')
-  _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<MixerTrack> > list_tracks(), gst_mixer_list_tracks)
+#m4 _CONVERSION(`const GList*', `Glib::ListHandle< Glib::RefPtr<Gst::MixerTrack> >', `$2(const_cast<GList*>($3), Glib::OWNERSHIP_NONE)')
+  _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<Gst::MixerTrack> > list_tracks(), gst_mixer_list_tracks)
 
   /** Get the current volume(s) on the given track.
    *
@@ -76,6 +78,41 @@
   _WRAP_METHOD(static void message_parse_volume_changed(GstMessage *message, GstMixerTrack **track, gint **volumes, gint *num_channels), gst_mixer_message_parse_volume_changed)
   _WRAP_METHOD(static void message_parse_options_list_changed(GstMessage *message, GstMixerOptions **options), gst_mixer_message_parse_options_list_changed)
   */
+
+//TODO:
+//#m4 _CONVERSION(`Glib::ListHandle< Glib::RefPtr<Gst::MixerTrack> >', `const GList*', `($3).data()')
+  //_WRAP_VFUNC(Glib::ListHandle< Glib::RefPtr<Gst::MixerTrack> > list_tracks(), "list_tracks")
+
+#m4 _CONVERSION(`GstMixerTrack*',`const Glib::RefPtr<Gst::MixerTrack>&', `Glib::wrap(($3), true)')
+
+#ifdef GLIBMM_VFUNCS_ENABLED
+// This vfunc is handcoded because we want to have it return the result instead
+// of requiring a pointer parameter in which to put it like the C API does.
+  virtual Glib::ArrayHandle<int> get_volume_vfunc(const Glib::RefPtr<Gst::MixerTrack>& track);
+#endif //GLIBMM_VFUNCS_ENABLED
+
+//TODO:
+  //_WRAP_VFUNC(void set_volume(const Glib::RefPtr<Gst::MixerTrack>& track, const Glib::ArrayHandle<int>& volumes), "set_volume")
+
+  _WRAP_VFUNC(void set_mute(const Glib::RefPtr<Gst::MixerTrack>& track, bool mute), "set_mute")
+  _WRAP_VFUNC(void set_record(const Glib::RefPtr<Gst::MixerTrack>& track, bool record), "set_record")
+
+#m4 _CONVERSION(`GstMixerOptions*',`const Glib::RefPtr<Gst::MixerOptions>&', `Glib::wrap(($3), true)')
+  _WRAP_VFUNC(void set_option(const Glib::RefPtr<Gst::MixerOptions>& opts, const Glib::ustring& value), "set_option")
+
+  //TODO:
+  //_WRAP_VFUNC(Glib::ustring get_option(const Glib::RefPtr<Gst::MixerOptions>& opts), "get_option")
+
+protected:
+#m4begin
+dnl// This vfunc callback is handcoded because we want to have the C++ vfunc
+dnl// return the result instead of passing in a pointer in which to store it.
+  _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
+    klass->get_volume = &get_volume_vfunc_callback;
+  _SECTION(SECTION_PH_VFUNCS)
+    static void get_volume_vfunc_callback(GstMixer* self, GstMixerTrack* track, gint* volumes);
+  _POP()
+#m4end
 };
 
 } // namespace Gst



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