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.
This commit is contained in:
Tim-Philipp Müller 2010-10-07 20:54:32 +01:00
parent 82d2669f4f
commit 4482cacb24

View file

@ -126,6 +126,9 @@ static GstElementClass *parent_class = NULL;
/*static guint gst_audio_rate_signals[LAST_SIGNAL] = { 0 }; */ /*static guint gst_audio_rate_signals[LAST_SIGNAL] = { 0 }; */
static GParamSpec *pspec_drop = NULL;
static GParamSpec *pspec_add = NULL;
static GType static GType
gst_audio_rate_get_type (void) 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_object_class_install_property (object_class, ARG_OUT,
g_param_spec_uint64 ("out", "Out", "Number of output samples", 0, g_param_spec_uint64 ("out", "Out", "Number of output samples", 0,
G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, ARG_ADD, pspec_add = g_param_spec_uint64 ("add", "Add", "Number of added samples",
g_param_spec_uint64 ("add", "Add", "Number of added samples", 0, 0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, ARG_ADD, pspec_add);
g_object_class_install_property (object_class, ARG_DROP, pspec_drop = g_param_spec_uint64 ("drop", "Drop", "Number of dropped samples",
g_param_spec_uint64 ("drop", "Drop", "Number of dropped samples", 0, 0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
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_object_class_install_property (object_class, ARG_SILENT,
g_param_spec_boolean ("silent", "silent", g_param_spec_boolean ("silent", "silent",
"Don't emit notify for dropped and duplicated frames", DEFAULT_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; 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 static GstFlowReturn
gst_audio_rate_chain (GstPad * pad, GstBuffer * buf) gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
{ {
@ -628,7 +651,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
audiorate->add += cursamples; audiorate->add += cursamples;
if (!audiorate->silent) if (!audiorate->silent)
g_object_notify (G_OBJECT (audiorate), "add"); gst_audio_rate_notify_add (audiorate);
} }
} else if (in_offset < audiorate->next_offset) { } else if (in_offset < audiorate->next_offset) {
@ -646,7 +669,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
buf = NULL; buf = NULL;
if (!audiorate->silent) if (!audiorate->silent)
g_object_notify (G_OBJECT (audiorate), "drop"); gst_audio_rate_notify_drop (audiorate);
goto beach; goto beach;
} else { } else {
@ -671,7 +694,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
truncsamples); truncsamples);
if (!audiorate->silent) if (!audiorate->silent)
g_object_notify (G_OBJECT (audiorate), "drop"); gst_audio_rate_notify_drop (audiorate);
} }
} }