[gst-cvs] gst-plugins-base: audiorate: use g_object_notify_by_pspec() if possible

Tim Müller tpm at kemper.freedesktop.org
Thu Oct 7 13:17:20 PDT 2010


Module: gst-plugins-base
Branch: master
Commit: 4482cacb2439eb94072dd1a7abf0e9474c56ea4f
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=4482cacb2439eb94072dd1a7abf0e9474c56ea4f

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Thu Oct  7 20:54:32 2010 +0100

audiorate: use g_object_notify_by_pspec() if possible

Use g_object_notify_by_pspec() when building against GLib >= 2.26.
This avoids the pspec lookup which takes the global paramspec pool lock.

---

 gst/audiorate/gstaudiorate.c |   41 ++++++++++++++++++++++++++++++++---------
 1 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/gst/audiorate/gstaudiorate.c b/gst/audiorate/gstaudiorate.c
index 9530a43..057115d 100644
--- a/gst/audiorate/gstaudiorate.c
+++ b/gst/audiorate/gstaudiorate.c
@@ -126,6 +126,9 @@ static GstElementClass *parent_class = NULL;
 
 /*static guint gst_audio_rate_signals[LAST_SIGNAL] = { 0 }; */
 
+static GParamSpec *pspec_drop = NULL;
+static GParamSpec *pspec_add = NULL;
+
 static GType
 gst_audio_rate_get_type (void)
 {
@@ -185,12 +188,12 @@ gst_audio_rate_class_init (GstAudioRateClass * klass)
   g_object_class_install_property (object_class, ARG_OUT,
       g_param_spec_uint64 ("out", "Out", "Number of output samples", 0,
           G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (object_class, ARG_ADD,
-      g_param_spec_uint64 ("add", "Add", "Number of added samples", 0,
-          G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (object_class, ARG_DROP,
-      g_param_spec_uint64 ("drop", "Drop", "Number of dropped samples", 0,
-          G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+  pspec_add = g_param_spec_uint64 ("add", "Add", "Number of added samples",
+      0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, ARG_ADD, pspec_add);
+  pspec_drop = g_param_spec_uint64 ("drop", "Drop", "Number of dropped samples",
+      0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, ARG_DROP, pspec_drop);
   g_object_class_install_property (object_class, ARG_SILENT,
       g_param_spec_boolean ("silent", "silent",
           "Don't emit notify for dropped and duplicated frames", DEFAULT_SILENT,
@@ -493,6 +496,26 @@ gst_audio_rate_convert_segments (GstAudioRate * audiorate)
   return TRUE;
 }
 
+static void
+gst_audio_rate_notify_drop (GstAudioRate * audiorate)
+{
+#if !GLIB_CHECK_VERSION(2,26,0)
+  g_object_notify ((GObject *) audiorate, "drop");
+#else
+  g_object_notify_by_pspec ((GObject *) audiorate, pspec_drop);
+#endif
+}
+
+static void
+gst_audio_rate_notify_add (GstAudioRate * audiorate)
+{
+#if !GLIB_CHECK_VERSION(2,26,0)
+  g_object_notify ((GObject *) audiorate, "add");
+#else
+  g_object_notify_by_pspec ((GObject *) audiorate, pspec_add);
+#endif
+}
+
 static GstFlowReturn
 gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
 {
@@ -628,7 +651,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
       audiorate->add += cursamples;
 
       if (!audiorate->silent)
-        g_object_notify (G_OBJECT (audiorate), "add");
+        gst_audio_rate_notify_add (audiorate);
     }
 
   } else if (in_offset < audiorate->next_offset) {
@@ -646,7 +669,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
       buf = NULL;
 
       if (!audiorate->silent)
-        g_object_notify (G_OBJECT (audiorate), "drop");
+        gst_audio_rate_notify_drop (audiorate);
 
       goto beach;
     } else {
@@ -671,7 +694,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
           truncsamples);
 
       if (!audiorate->silent)
-        g_object_notify (G_OBJECT (audiorate), "drop");
+        gst_audio_rate_notify_drop (audiorate);
     }
   }
 





More information about the Gstreamer-commits mailing list