[gstreamermm] Mixer: Use std::vector<> instead of Glib::[Array|List]Handle<>.
- From: José Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Mixer: Use std::vector<> instead of Glib::[Array|List]Handle<>.
- Date: Thu, 28 Apr 2011 22:50:03 +0000 (UTC)
commit 1fc5f8e67323d144e7cdb35e9c040a59022f7ecd
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Thu Apr 28 18:48:52 2011 -0400
Mixer: Use std::vector<> instead of Glib::[Array|List]Handle<>.
* gstreamer/src/mixer.{ccg,hg}: Wrap the
MessageMixerVolumeChanged::parse() method taking a track and an array
of volumes output parameter. Use std::vector<> for the parameters and
return of methods instead of Glib::ArrayHandle<> throughout for
consistency.
* gstreamer/gstreamermm.h: Corrected a couple of TODO's.
ChangeLog | 12 ++++++++++
gstreamer/gstreamermm.h | 4 +-
gstreamer/src/mixer.ccg | 36 +++++++++++++++++------------
gstreamer/src/mixer.hg | 57 +++++++++++++++++++++++------------------------
4 files changed, 63 insertions(+), 46 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 968a618..ed571ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2011-04-28 José Alburquerque <jaalburqu svn gnome org>
+ Mixer: Use std::vector<> instead of Glib::[Array|List]Handle<>.
+
+ * gstreamer/src/mixer.{ccg,hg}: Wrap the
+ MessageMixerVolumeChanged::parse() method taking a track and an array
+ of volumes output parameter. Use std::vector<> for the parameters and
+ return of methods instead of Glib::ArrayHandle<> throughout for
+ consistency.
+
+ * gstreamer/gstreamermm.h: Corrected a couple of TODO's.
+
+2011-04-28 José Alburquerque <jaalburqu svn gnome org>
+
AudioSink, AudioSrc: Wrap the virtual functions.
* gstreamer/src/audiosink.hg:
diff --git a/gstreamer/gstreamermm.h b/gstreamer/gstreamermm.h
index e923bd3..426025c 100644
--- a/gstreamer/gstreamermm.h
+++ b/gstreamer/gstreamermm.h
@@ -172,8 +172,8 @@
#include <gstreamermm/giosrc.h>
#include <gstreamermm/giostreamsink.h>
#include <gstreamermm/giostreamsrc.h>
-//TODO (Add plug-in first): #include <gstreamermm/gnomevfssink.h>
-//TODO (Add plug-in first): #include <gstreamermm/gnomevfssrc.h>
+//TODO? (Add plug-in first): #include <gstreamermm/gnomevfssink.h>
+//TODO? (Add plug-in first): #include <gstreamermm/gnomevfssrc.h>
#include <gstreamermm/multifdsink.h>
#include <gstreamermm/oggdemux.h>
#include <gstreamermm/oggmux.h>
diff --git a/gstreamer/src/mixer.ccg b/gstreamer/src/mixer.ccg
index 93aa63b..821673c 100644
--- a/gstreamer/src/mixer.ccg
+++ b/gstreamer/src/mixer.ccg
@@ -18,6 +18,7 @@
*/
#include <gstreamermm/mixeroptions.h>
+#include <glibmm/vectorutils.h>
namespace Gst
{
@@ -98,10 +99,8 @@ MessageMixerVolumeChanged::MessageMixerVolumeChanged(GstMessage* castitem)
: Message(castitem)
{}
-//TODO: Include when = operator is available for Glib::ArrayHandle<>.
-/*
void MessageMixerVolumeChanged::parse(Glib::RefPtr<Gst::MixerTrack>& track,
- Glib::ArrayHandle<int>& volumes) const
+ std::vector<int>& volumes) const
{
GstMixerTrack* gst_track = 0;
gint* gst_volumes = 0;
@@ -109,11 +108,12 @@ void MessageMixerVolumeChanged::parse(Glib::RefPtr<Gst::MixerTrack>& track,
gst_mixer_message_parse_volume_changed(const_cast<GstMessage*>(gobj()),
&gst_track, &gst_volumes, &gst_num_channels);
+
track = Glib::wrap(gst_track);
- //TODO: = is private for Glib::ArrayHandle:
- //volumes = Glib::ArrayHandle<int>(gst_volumes, gst_num_channels, Glib::OWNERSHIP_DEEP);
+
+ volumes = Glib::ArrayHandler<int>::array_to_vector(gst_volumes,
+ gst_num_channels, Glib::OWNERSHIP_DEEP);
}
-*/
Glib::RefPtr<Gst::MixerTrack> MessageMixerVolumeChanged::parse()
{
@@ -127,13 +127,16 @@ Glib::RefPtr<const Gst::MixerTrack> MessageMixerVolumeChanged::parse() const
return parse();
}
-Glib::ArrayHandle<int> MessageMixerVolumeChanged::parse_volumes() const
+std::vector<int> MessageMixerVolumeChanged::parse_volumes() const
{
gint* gst_volumes = 0;
gint gst_num_channels = 0;
+
gst_mixer_message_parse_volume_changed(const_cast<GstMessage*>(gobj()),
0, &gst_volumes, &gst_num_channels);
- return Glib::ArrayHandle<int>(gst_volumes, gst_num_channels, Glib::OWNERSHIP_DEEP);
+
+ return Glib::ArrayHandle<int>(gst_volumes, gst_num_channels,
+ Glib::OWNERSHIP_DEEP);
}
MessageMixerOptionChanged::MessageMixerOptionChanged(GstMessage* castitem)
@@ -193,7 +196,7 @@ MessageMixerChanged::MessageMixerChanged(GstMessage* castitem)
: Message(castitem)
{}
-Glib::ArrayHandle<int> Mixer::get_volume(const Glib::RefPtr<const Gst::MixerTrack>& track) const
+std::vector<int> Mixer::get_volume(const Glib::RefPtr<const Gst::MixerTrack>& track) const
{
const guint32 num_channels = track->get_num_channels();
int* volumes = g_new(int, num_channels);
@@ -222,11 +225,10 @@ void Mixer_Class::get_volume_vfunc_callback(GstMixer* self, GstMixerTrack* track
try // Trap C++ exceptions which would normally be lost because this is a C callback.
{
// 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();
+ std::vector<int> result = obj->get_volume_vfunc(Glib::wrap(track, true));
for(guint i = 0; i < result.size(); i++)
{
- volumes[i] = result_data[i];
+ volumes[i] = result[i];
}
}
catch(...)
@@ -246,7 +248,7 @@ g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Ge
return (*base->get_volume)(self, track, volumes);
}
}
-Glib::ArrayHandle<int> Gst::Mixer::get_volume_vfunc(const Glib::RefPtr<const Gst::MixerTrack>& track) const
+std::vector<int> Gst::Mixer::get_volume_vfunc(const Glib::RefPtr<const Gst::MixerTrack>& track) const
{
BaseClassType *const base = static_cast<BaseClassType*>(
g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
@@ -256,9 +258,11 @@ g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) /
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*>(Glib::unwrap(track)), volumes);
+
return Glib::ArrayHandle<int>(volumes, num_channels, Glib::OWNERSHIP_DEEP);
}
@@ -283,7 +287,9 @@ const GList* Mixer_Class::list_tracks_vfunc_callback(GstMixer* self)
try // Trap C++ exceptions which would normally be lost because this is a C callback.
{
// Call the virtual member method, which derived classes might override.
- return (obj->list_tracks_vfunc()).data();
+ return
+ Glib::ListHandler< Glib::RefPtr<Gst::MixerTrack> >::vector_to_list(
+ obj->list_tracks_vfunc()).data();
}
catch(...)
{
@@ -305,7 +311,7 @@ g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Ge
typedef const GList* RType;
return RType();
}
-Glib::ListHandle< Glib::RefPtr<Gst::MixerTrack> > Gst::Mixer::list_tracks_vfunc() const
+std::vector< Glib::RefPtr<Gst::MixerTrack> > Gst::Mixer::list_tracks_vfunc()
{
BaseClassType *const base = static_cast<BaseClassType*>(
g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
diff --git a/gstreamer/src/mixer.hg b/gstreamer/src/mixer.hg
index bb4e53c..5161b8c 100644
--- a/gstreamer/src/mixer.hg
+++ b/gstreamer/src/mixer.hg
@@ -43,25 +43,25 @@ class Mixer : public Glib::Interface
_CLASS_INTERFACE(Mixer, GstMixer, GST_MIXER, GstMixerClass)
public:
-#m4 _CONVERSION(`const GList*', `Glib::ListHandle< Glib::RefPtr<Gst::MixerTrack> >', `$2(const_cast<GList*>($3), Glib::OWNERSHIP_NONE)')
+#m4 _CONVERSION(`const GList*', `std::vector< Glib::RefPtr<Gst::MixerTrack> >', `Glib::ListHandler< Glib::RefPtr<Gst::MixerTrack> >::list_to_vector(const_cast<GList*>($3), Glib::OWNERSHIP_NONE)')
/** Returns a list of available tracks for this mixer/element. Note that it
* is allowed for sink (output) elements to only provide the output tracks
* in this list. Likewise, for sources (inputs), it is allowed to only
* provide input elements in this list.
*
- * @return A Glib::ListHandle<> consisting of zero or more Gst::MixerTrack.
+ * @return A std::vector<> consisting of zero or more Gst::MixerTrack.
*/
- _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<Gst::MixerTrack> > list_tracks(), gst_mixer_list_tracks)
+ _WRAP_METHOD(std::vector< Glib::RefPtr<Gst::MixerTrack> > list_tracks(), gst_mixer_list_tracks)
-#m4 _CONVERSION(`const GList*', `Glib::ListHandle< Glib::RefPtr<const Gst::MixerTrack> >', `$2(const_cast<GList*>($3), Glib::OWNERSHIP_NONE)')
+#m4 _CONVERSION(`const GList*', `std::vector< Glib::RefPtr<const Gst::MixerTrack> >', `Glib::ListHandler< Glib::RefPtr<const Gst::MixerTrack> >::list_to_vector(const_cast<GList*>($3), Glib::OWNERSHIP_NONE)')
/** Returns a list of available tracks for this mixer/element. Note that it
* is allowed for sink (output) elements to only provide the output tracks
* in this list. Likewise, for sources (inputs), it is allowed to only
* provide input elements in this list.
*
- * @return A Glib::ListHandle<> consisting of zero or more Gst::MixerTrack.
+ * @return A std::vector<> consisting of zero or more Gst::MixerTrack.
*/
- _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<const Gst::MixerTrack> > list_tracks() const, gst_mixer_list_tracks)
+ _WRAP_METHOD(std::vector< Glib::RefPtr<const Gst::MixerTrack> > list_tracks() const, gst_mixer_list_tracks)
/** Get the current volume(s) on the given track.
*
@@ -69,18 +69,18 @@ public:
* @return an array of integers (of size track->num_channels) to with the
* current volume of each channel in the given track.
*/
- Glib::ArrayHandle<int> get_volume(const Glib::RefPtr<const Gst::MixerTrack>& track) const;
+ std::vector<int> get_volume(const Glib::RefPtr<const Gst::MixerTrack>& track) const;
_IGNORE(gst_mixer_get_volume)
-#m4 _CONVERSION(`const Glib::ArrayHandle<int>&', `gint*', `const_cast<int*>(($3).data())')
- _WRAP_METHOD(void set_volume(const Glib::RefPtr<Gst::MixerTrack>& track, const Glib::ArrayHandle<int>& volumes), gst_mixer_set_volume)
+#m4 _CONVERSION(`const std::vector<int>&', `gint*', `Glib::ArrayHandler<int>::vector_to_array($3).data()')
+ _WRAP_METHOD(void set_volume(const Glib::RefPtr<Gst::MixerTrack>& track, const std::vector<int>& volumes), gst_mixer_set_volume)
_WRAP_METHOD(void set_mute(const Glib::RefPtr<Gst::MixerTrack>& track, bool mute), gst_mixer_set_mute)
_WRAP_METHOD(void set_record(const Glib::RefPtr<Gst::MixerTrack>& track, bool record), gst_mixer_set_record)
_WRAP_METHOD(void set_option(const Glib::RefPtr<Gst::MixerOptions>& opts, const Glib::ustring& value), gst_mixer_set_option)
_WRAP_METHOD(void mute_toggled(const Glib::RefPtr<Gst::MixerTrack>& track, bool mute), gst_mixer_mute_toggled)
_WRAP_METHOD(void record_toggled(const Glib::RefPtr<Gst::MixerTrack>& track, bool record), gst_mixer_record_toggled)
- _WRAP_METHOD(void volume_changed(const Glib::RefPtr<Gst::MixerTrack>& track, const Glib::ArrayHandle<int>& volumes), gst_mixer_volume_changed)
+ _WRAP_METHOD(void volume_changed(const Glib::RefPtr<Gst::MixerTrack>& track, const std::vector<int>& volumes), gst_mixer_volume_changed)
_WRAP_METHOD(void option_changed(const Glib::RefPtr<Gst::MixerOptions>& opts, const Glib::ustring& value), gst_mixer_option_changed)
_WRAP_METHOD(void options_list_changed(const Glib::RefPtr<Gst::MixerOptions>& opts), gst_mixer_options_list_changed)
_WRAP_METHOD(Glib::ustring get_option(const Glib::RefPtr<const Gst::MixerOptions>& opts) const, gst_mixer_get_option)
@@ -94,13 +94,14 @@ public:
// Gst::MessageMixer* classes):
_IGNORE_SIGNAL(mute_toggled, record_toggled, volume_changed, option_changed)
- virtual Glib::ArrayHandle<int> get_volume_vfunc(const Glib::RefPtr<const Gst::MixerTrack>& track) const;
- virtual Glib::ListHandle< Glib::RefPtr<Gst::MixerTrack> > list_tracks_vfunc() const;
+ virtual std::vector<int> get_volume_vfunc(const Glib::RefPtr<const Gst::MixerTrack>& track) const;
+
+ virtual std::vector< Glib::RefPtr<Gst::MixerTrack> > list_tracks_vfunc();
#m4 _CONVERSION(`GstMixerTrack*',`const Glib::RefPtr<Gst::MixerTrack>&', `Glib::wrap(($3), true)')
-#m4 _CONVERSION(`gint*', `const Glib::ArrayHandle<int>&', `Glib::ArrayHandle<int>(($3), Glib::OWNERSHIP_NONE)')
- _WRAP_VFUNC(void set_volume(const Glib::RefPtr<Gst::MixerTrack>& track, const Glib::ArrayHandle<int>& volumes), "set_volume")
+#m4 _CONVERSION(`gint*', `const std::vector<int>&', `Glib::ArrayHandler<int>::array_to_vector(($3), Glib::OWNERSHIP_NONE)')
+ _WRAP_VFUNC(void set_volume(const Glib::RefPtr<Gst::MixerTrack>& track, const std::vector<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")
@@ -226,20 +227,18 @@ class MessageMixerVolumeChanged : public Message
public:
explicit MessageMixerVolumeChanged(GstMessage* castitem);
- //TODO: Include when = operator is available for Glib::ArrayHandle<>.
- ///** Parses a volume-changed notification message and extracts the track
- //* object it refers to, as well as an array of volumes and the size of the
- //* volumes array.
- //*
- //* The track object remains valid until the message is freed.
- //*
- //* @param track A reference to hold a Gst::MixerTrack object.
- //* @param volumes A reference to receive an array of int values.
- //*
- //* Since 0.10.14.
- //*/
- //void parse(Glib::RefPtr<Gst::MixerTrack>& track,
- //Glib::ArrayHandle<int>& volumes) const;
+ /** Parses a volume-changed notification message and extracts the track
+ * object it refers to, as well as an array of volumes and the size of the
+ * volumes array.
+ *
+ * The track object remains valid until the message is freed.
+ *
+ * @param track A reference to hold a Gst::MixerTrack object.
+ * @param volumes A reference to receive an array of int values.
+ *
+ * Since 0.10.14.
+ */
+ void parse(Glib::RefPtr<Gst::MixerTrack>& track, std::vector<int>& volumes) const;
_IGNORE(gst_mixer_message_parse_volume_changed)
/** Parses a volume-changed notification message and extracts the track
@@ -265,7 +264,7 @@ public:
*
* @return The array of volume int values.
*/
- Glib::ArrayHandle<int> parse_volumes() const;
+ std::vector<int> parse_volumes() const;
};
/** An option-changed Gst::Mixer message.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]