diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2007-02-02 18:36:28 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2007-02-02 18:36:28 +0000 |
commit | d5bd74dcf6384ef42b66658d8826b6d5d6eaa76d (patch) | |
tree | cc492d48c0e2bdec773f831b908d9f776742e50e /gst | |
parent | c2306bc88fd5fd471e4778c9876ea4c4a3759b53 (diff) | |
download | gst-plugins-bad-d5bd74dcf6384ef42b66658d8826b6d5d6eaa76d.tar.gz gst-plugins-bad-d5bd74dcf6384ef42b66658d8826b6d5d6eaa76d.tar.bz2 gst-plugins-bad-d5bd74dcf6384ef42b66658d8826b6d5d6eaa76d.zip |
gst/equalizer/gstiirequalizer.c: Rename "values" property to "band-values" and change type into a
Original commit message from CVS:
* gst/equalizer/gstiirequalizer.c: (gst_iir_equalizer_class_init),
(gst_iir_equalizer_set_property), (gst_iir_equalizer_get_property),
(gst_iir_equalizer_filter_inplace):
Rename "values" property to "band-values" and change type into a
GValueArray, so it's more easily bindable and the range of the
values passed in is defined and checked etc.; also do some
locking.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/equalizer/gstiirequalizer.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/gst/equalizer/gstiirequalizer.c b/gst/equalizer/gstiirequalizer.c index dae20fe5..fd8f3781 100644 --- a/gst/equalizer/gstiirequalizer.c +++ b/gst/equalizer/gstiirequalizer.c @@ -81,8 +81,7 @@ enum ARG_0, ARG_BANDS, ARG_BANDWIDTH, - ARG_VALUES - /* FILL ME */ + ARG_BAND_VALUES }; static void gst_iir_equalizer_base_init (gpointer g_class); @@ -176,10 +175,12 @@ gst_iir_equalizer_class_init (gpointer g_class, gpointer class_data) g_param_spec_double ("bandwidth", "bandwidth", "bandwidth calculated as distance between bands * this value", 0.1, 5.0, 1.0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - /* FIXME FIXME FIXME */ - g_object_class_install_property (gobject_class, ARG_VALUES, - g_param_spec_pointer ("values", "values", - "expects a gdouble* of values to use for the bands", + g_object_class_install_property (gobject_class, ARG_BAND_VALUES, + g_param_spec_value_array ("band-values", "band values", + "GValueArray holding gdouble values, one for each band with values " + "ranging from -1.0 to +1.0", + g_param_spec_double ("band-value", "band-value", + "Equaliser Band Value", -1.0, 1.0, 0.0, G_PARAM_WRITABLE), G_PARAM_WRITABLE)); audio_filter_class->setup = gst_iir_equalizer_setup; @@ -281,6 +282,7 @@ gst_iir_equalizer_set_property (GObject * object, guint prop_id, { GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); + GST_OBJECT_LOCK (equ); switch (prop_id) { case ARG_BANDS: gst_iir_equalizer_compute_frequencies (equ, g_value_get_uint (value)); @@ -298,24 +300,36 @@ gst_iir_equalizer_set_property (GObject * object, guint prop_id, } } break; - case ARG_VALUES: - { - gdouble *new = g_value_get_pointer (value); - guint i; - - for (i = 0; i < equ->freq_count; i++) { - if (new[i] != equ->values[i]) { - equ->values[i] = new[i]; - setup_filter (equ, &equ->filter[i], arg_to_scale (new[i]), - equ->freqs[i] / GST_AUDIO_FILTER (equ)->rate); + case ARG_BAND_VALUES:{ + GValueArray *arr; + + arr = (GValueArray *) g_value_get_boxed (value); + if (arr == NULL) { + g_warning ("Application tried to set empty band value array"); + } else if (arr->n_values != equ->freq_count) { + g_warning ("Application tried to set %u band values, but there are " + "%u bands", arr->n_values, equ->freq_count); + } else { + guint i; + + for (i = 0; i < arr->n_values; ++i) { + gdouble new_val; + + new_val = g_value_get_double (g_value_array_get_nth (arr, i)); + if (new_val != equ->values[i]) { + equ->values[i] = new_val; + setup_filter (equ, &equ->filter[i], arg_to_scale (new_val), + equ->freqs[i] / GST_AUDIO_FILTER (equ)->rate); + } } } - } break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } + GST_OBJECT_UNLOCK (equ); } static void @@ -324,6 +338,7 @@ gst_iir_equalizer_get_property (GObject * object, guint prop_id, { GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); + GST_OBJECT_LOCK (equ); switch (prop_id) { case ARG_BANDS: g_value_set_uint (value, equ->freq_count); @@ -335,6 +350,7 @@ gst_iir_equalizer_get_property (GObject * object, guint prop_id, G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } + GST_OBJECT_UNLOCK (equ); } /* start of code that is type specific */ @@ -400,8 +416,10 @@ gst_iir_equalizer_filter_inplace (GstAudioFilter * filter, GstBuffer * buf) { GstIirEqualizer *equ = GST_IIR_EQUALIZER (filter); + GST_OBJECT_LOCK (equ); equ->process (equ, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), filter->channels); + GST_OBJECT_UNLOCK (equ); } static void |