spectrum: improve property setter

consistently only update if the property actualy changed the value. Do it
without reading the gvalue twice. No need to reset the spectrum analyzer for
threshold changes.
This commit is contained in:
Stefan Kost 2010-08-11 15:40:09 +03:00
parent 61f22f4379
commit 50a139de85

View file

@ -331,31 +331,28 @@ gst_spectrum_set_property (GObject * object, guint prop_id,
case PROP_MESSAGE_PHASE: case PROP_MESSAGE_PHASE:
filter->message_phase = g_value_get_boolean (value); filter->message_phase = g_value_get_boolean (value);
break; break;
case PROP_INTERVAL: case PROP_INTERVAL:{
GST_BASE_TRANSFORM_LOCK (filter); guint64 interval = g_value_get_uint64 (value);
filter->interval = g_value_get_uint64 (value); if (filter->interval != interval) {
gst_spectrum_reset_state (filter); GST_BASE_TRANSFORM_LOCK (filter);
GST_BASE_TRANSFORM_UNLOCK (filter); filter->interval = g_value_get_uint64 (value);
break; gst_spectrum_reset_state (filter);
case PROP_BANDS:
GST_BASE_TRANSFORM_LOCK (filter);
if (filter->bands == g_value_get_uint (value)) {
GST_BASE_TRANSFORM_UNLOCK (filter); GST_BASE_TRANSFORM_UNLOCK (filter);
break;
} }
}
filter->bands = g_value_get_uint (value); break;
case PROP_BANDS:{
gst_spectrum_reset_state (filter); guint bands = g_value_get_uint (value);
if (filter->bands != bands) {
GST_BASE_TRANSFORM_UNLOCK (filter); GST_BASE_TRANSFORM_LOCK (filter);
filter->bands = bands;
gst_spectrum_reset_state (filter);
GST_BASE_TRANSFORM_UNLOCK (filter);
}
}
break; break;
case PROP_THRESHOLD: case PROP_THRESHOLD:
GST_BASE_TRANSFORM_LOCK (filter);
filter->threshold = g_value_get_int (value); filter->threshold = g_value_get_int (value);
gst_spectrum_reset_state (filter);
GST_BASE_TRANSFORM_UNLOCK (filter);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);