📄 gstlfocontrolsource.c
字号:
if (!G_IS_VALUE (&self->priv->amplitude)) { g_value_init (&self->priv->amplitude, type); g_value_set_ulong (&self->priv->amplitude, 0); } if (!G_IS_VALUE (&self->priv->offset)) { g_value_init (&self->priv->offset, type); g_value_set_ulong (&self->priv->offset, tpspec->default_value); } break; } case G_TYPE_INT64:{ GParamSpecInt64 *tpspec = G_PARAM_SPEC_INT64 (pspec); g_value_init (&self->priv->minimum_value, type); g_value_set_int64 (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_int64 (&self->priv->maximum_value, tpspec->maximum); if (!G_IS_VALUE (&self->priv->amplitude)) { g_value_init (&self->priv->amplitude, type); g_value_set_int64 (&self->priv->amplitude, 0); } if (!G_IS_VALUE (&self->priv->offset)) { g_value_init (&self->priv->offset, type); g_value_set_int64 (&self->priv->offset, tpspec->default_value); } break; } case G_TYPE_UINT64:{ GParamSpecUInt64 *tpspec = G_PARAM_SPEC_UINT64 (pspec); g_value_init (&self->priv->minimum_value, type); g_value_set_uint64 (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_uint64 (&self->priv->maximum_value, tpspec->maximum); if (!G_IS_VALUE (&self->priv->amplitude)) { g_value_init (&self->priv->amplitude, type); g_value_set_uint64 (&self->priv->amplitude, 0); } if (!G_IS_VALUE (&self->priv->offset)) { g_value_init (&self->priv->offset, type); g_value_set_uint64 (&self->priv->offset, tpspec->default_value); } break; } case G_TYPE_FLOAT:{ GParamSpecFloat *tpspec = G_PARAM_SPEC_FLOAT (pspec); g_value_init (&self->priv->minimum_value, type); g_value_set_float (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_float (&self->priv->maximum_value, tpspec->maximum); if (!G_IS_VALUE (&self->priv->amplitude)) { g_value_init (&self->priv->amplitude, type); g_value_set_float (&self->priv->amplitude, 0.0); } if (!G_IS_VALUE (&self->priv->offset)) { g_value_init (&self->priv->offset, type); g_value_set_float (&self->priv->offset, tpspec->default_value); } break; } case G_TYPE_DOUBLE:{ GParamSpecDouble *tpspec = G_PARAM_SPEC_DOUBLE (pspec); g_value_init (&self->priv->minimum_value, type); g_value_set_double (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_double (&self->priv->maximum_value, tpspec->maximum); if (!G_IS_VALUE (&self->priv->amplitude)) { g_value_init (&self->priv->amplitude, type); g_value_set_float (&self->priv->amplitude, 0.0); } if (!G_IS_VALUE (&self->priv->offset)) { g_value_init (&self->priv->offset, type); g_value_set_float (&self->priv->offset, tpspec->default_value); } break; } default: GST_WARNING ("incomplete implementation for paramspec type '%s'", G_PARAM_SPEC_TYPE_NAME (pspec)); ret = FALSE; break; } if (ret) { GValue amp = { 0, } , off = { 0,}; /* This should never fail unless the user already set amplitude or offset * with an incompatible type before _bind () */ if (!g_value_type_transformable (G_VALUE_TYPE (&self->priv->amplitude), base) || !g_value_type_transformable (G_VALUE_TYPE (&self->priv->offset), base)) { GST_WARNING ("incompatible types for amplitude or offset"); gst_lfo_control_source_reset (self); return FALSE; } /* Generate copies and transform to the correct type */ g_value_init (&, base); g_value_transform (&self->priv->amplitude, &); g_value_init (&off, base); g_value_transform (&self->priv->offset, &off); ret = gst_lfo_control_source_set_waveform (self, self->priv->waveform); g_value_unset (&self->priv->amplitude); g_value_init (&self->priv->amplitude, self->priv->base); g_value_transform (&, &self->priv->amplitude); g_value_unset (&self->priv->offset); g_value_init (&self->priv->offset, self->priv->base); g_value_transform (&off, &self->priv->offset); g_value_unset (&); g_value_unset (&off); } if (!ret) gst_lfo_control_source_reset (self); return ret;}static voidgst_lfo_control_source_init (GstLFOControlSource * self){ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_LFO_CONTROL_SOURCE, GstLFOControlSourcePrivate); self->priv->waveform = GST_LFO_WAVEFORM_SINE; self->priv->frequency = 1.0; self->priv->period = GST_SECOND / self->priv->frequency; self->priv->timeshift = 0; self->lock = g_mutex_new ();}static voidgst_lfo_control_source_finalize (GObject * obj){ GstLFOControlSource *self = GST_LFO_CONTROL_SOURCE (obj); gst_lfo_control_source_reset (self); if (self->lock) { g_mutex_free (self->lock); self->lock = NULL; } G_OBJECT_CLASS (parent_class)->finalize (obj);}static voidgst_lfo_control_source_dispose (GObject * obj){ G_OBJECT_CLASS (parent_class)->dispose (obj);}static voidgst_lfo_control_source_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec){ GstLFOControlSource *self = GST_LFO_CONTROL_SOURCE (object); switch (prop_id) { case PROP_WAVEFORM: g_mutex_lock (self->lock); gst_lfo_control_source_set_waveform (self, g_value_get_enum (value)); g_mutex_unlock (self->lock); break; case PROP_FREQUENCY:{ gdouble frequency = g_value_get_double (value); g_return_if_fail (frequency > 0 || ((GstClockTime) (GST_SECOND / frequency)) != 0); g_mutex_lock (self->lock); self->priv->frequency = frequency; self->priv->period = GST_SECOND / frequency; g_mutex_unlock (self->lock); break; } case PROP_TIMESHIFT: g_mutex_lock (self->lock); self->priv->timeshift = g_value_get_uint64 (value); g_mutex_unlock (self->lock); break; case PROP_AMPLITUDE:{ GValue *val = g_value_get_boxed (value); if (self->priv->type != G_TYPE_INVALID) { g_return_if_fail (g_value_type_transformable (self->priv->type, G_VALUE_TYPE (val))); g_mutex_lock (self->lock); if (G_IS_VALUE (&self->priv->amplitude)) g_value_unset (&self->priv->amplitude); g_value_init (&self->priv->amplitude, self->priv->type); g_value_transform (val, &self->priv->amplitude); g_mutex_unlock (self->lock); } else { g_mutex_lock (self->lock); if (G_IS_VALUE (&self->priv->amplitude)) g_value_unset (&self->priv->amplitude); g_value_init (&self->priv->amplitude, G_VALUE_TYPE (val)); g_value_copy (val, &self->priv->amplitude); g_mutex_unlock (self->lock); } break; } case PROP_OFFSET:{ GValue *val = g_value_get_boxed (value); if (self->priv->type != G_TYPE_INVALID) { g_return_if_fail (g_value_type_transformable (self->priv->type, G_VALUE_TYPE (val))); g_mutex_lock (self->lock); if (G_IS_VALUE (&self->priv->offset)) g_value_unset (&self->priv->offset); g_value_init (&self->priv->offset, self->priv->type); g_value_transform (val, &self->priv->offset); g_mutex_unlock (self->lock); } else { g_mutex_lock (self->lock); if (G_IS_VALUE (&self->priv->offset)) g_value_unset (&self->priv->offset); g_value_init (&self->priv->offset, G_VALUE_TYPE (val)); g_value_copy (val, &self->priv->offset); g_mutex_unlock (self->lock); } break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; }}static voidgst_lfo_control_source_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec){ GstLFOControlSource *self = GST_LFO_CONTROL_SOURCE (object); switch (prop_id) { case PROP_WAVEFORM: g_value_set_enum (value, self->priv->waveform); break; case PROP_FREQUENCY: g_value_set_double (value, self->priv->frequency); break; case PROP_TIMESHIFT: g_value_set_uint64 (value, self->priv->timeshift); break; case PROP_AMPLITUDE: g_value_set_boxed (value, &self->priv->amplitude); break; case PROP_OFFSET: g_value_set_boxed (value, &self->priv->offset); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; }}static voidgst_lfo_control_source_class_init (GstLFOControlSourceClass * klass){ GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstControlSourceClass *csource_class = GST_CONTROL_SOURCE_CLASS (klass); parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (GstLFOControlSourcePrivate)); gobject_class->finalize = gst_lfo_control_source_finalize; gobject_class->dispose = gst_lfo_control_source_dispose; gobject_class->set_property = gst_lfo_control_source_set_property; gobject_class->get_property = gst_lfo_control_source_get_property; csource_class->bind = gst_lfo_control_source_bind; /** * GstLFOControlSource:waveform * * Specifies the waveform that should be used for this #GstLFOControlSource. * **/ g_object_class_install_property (gobject_class, PROP_WAVEFORM, g_param_spec_enum ("waveform", "Waveform", "Waveform", GST_TYPE_LFO_WAVEFORM, GST_LFO_WAVEFORM_SINE, G_PARAM_READWRITE)); /** * GstLFOControlSource:frequency * * Specifies the frequency that should be used for the waveform * of this #GstLFOControlSource. It should be large enough * so that the period is longer than one nanosecond. * **/ g_object_class_install_property (gobject_class, PROP_FREQUENCY, g_param_spec_double ("frequency", "Frequency", "Frequency of the waveform", 0.0, G_MAXDOUBLE, 1.0, G_PARAM_READWRITE)); /** * GstLFOControlSource:timeshift * * Specifies the timeshift to the right that should be used for the waveform * of this #GstLFOControlSource in nanoseconds. * * To get a n nanosecond shift to the left use * "(GST_SECOND / frequency) - n". * **/ g_object_class_install_property (gobject_class, PROP_TIMESHIFT, g_param_spec_uint64 ("timeshift", "Timeshift", "Timeshift of the waveform to the right", 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); /** * GstLFOControlSource:amplitude * * Specifies the amplitude for the waveform of this #GstLFOControlSource. * * It should be given as a #GValue with a type that can be transformed * to the type of the bound property. **/ g_object_class_install_property (gobject_class, PROP_AMPLITUDE, g_param_spec_boxed ("amplitude", "Amplitude", "Amplitude of the waveform", G_TYPE_VALUE, G_PARAM_READWRITE)); /** * GstLFOControlSource:offset * * Specifies the offset for the waveform of this #GstLFOControlSource. * * It should be given as a #GValue with a type that can be transformed * to the type of the bound property. **/ g_object_class_install_property (gobject_class, PROP_OFFSET, g_param_spec_boxed ("offset", "Offset", "Offset of the waveform", G_TYPE_VALUE, G_PARAM_READWRITE));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -