gst_controller_set_property_disabled -> gst_object_set_controlled_property_disabled
gst_object_get_value_arrays has been removed. Loop over the controlled
- properties fetch the value array.
+ properties fetch the value array. Also GstValueArray is gone. The fields of
+ GstValueArray are now passed directly to gst_object_get_value_array as
+ arguments.
*/
gboolean
gst_control_source_get_value_array (GstControlSource * self,
- GstClockTime timestamp, GstValueArray * value_array)
+ GstClockTime timestamp, GstClockTime interval, guint n_values,
+ gpointer * values)
{
g_return_val_if_fail (GST_IS_CONTROL_SOURCE (self), FALSE);
if (G_LIKELY (self->get_value_array)) {
- return self->get_value_array (self, timestamp, value_array);
+ return self->get_value_array (self, timestamp, interval, n_values, values);
} else {
GST_ERROR ("Not bound to a specific property yet!");
return FALSE;
};
/**
- * GstValueArray:
- * @property_name: the name of the property this array belongs to
- * @nbsamples: number of samples requested
- * @sample_interval: interval between each sample
- * @values: pointer to the array
- *
- * Structure to receive multiple values at once.
- */
-struct _GstValueArray
-{
- const gchar *property_name;
- gint nbsamples;
- GstClockTime sample_interval;
- gpointer *values;
-};
-
-/**
* GstControlSourceGetValue
* @self: the #GstControlSource instance
* @timestamp: timestamp for which a value should be calculated
* Returns: %TRUE if the value was successfully calculated.
*
*/
-typedef gboolean (* GstControlSourceGetValue) (GstControlSource *self, GstClockTime timestamp, GValue *value);
+typedef gboolean (* GstControlSourceGetValue) (GstControlSource *self,
+ GstClockTime timestamp, GValue *value);
/**
* GstControlSourceGetValueArray
* @self: the #GstControlSource instance
* @timestamp: timestamp for which a value should be calculated
- * @value_array: array to put control-values in
+ * @interval: the time spacing between subsequent values
+ * @n_values: the number of values
+ * @values: array to put control-values in
*
- * Function for returning a #GstValueArray for a given timestamp.
+ * Function for returning an array of values for starting at a given timestamp.
*
* Returns: %TRUE if the values were successfully calculated.
*
*/
-typedef gboolean (* GstControlSourceGetValueArray) (GstControlSource *self, GstClockTime timestamp, GstValueArray *value_array);
+typedef gboolean (* GstControlSourceGetValueArray) (GstControlSource *self,
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *values);
/**
* GstControlSourceBind
gboolean gst_control_source_get_value (GstControlSource *self, GstClockTime timestamp,
GValue *value);
gboolean gst_control_source_get_value_array (GstControlSource *self, GstClockTime timestamp,
- GstValueArray *value_array);
+ GstClockTime interval, guint n_values,
+ gpointer *values);
gboolean gst_control_source_bind (GstControlSource *self, GParamSpec *pspec);
/**
* gst_object_get_value_array:
* @object: the object that has controlled properties
+ * @property_name: the name of the property to get
* @timestamp: the time that should be processed
- * @value_array: array to put control-values in
- *
- * Function to be able to get an array of values for one element properties
+ * @interval: the time spacing between subsequent values
+ * @n_values: the number of values
+ * @values: array to put control-values in
*
- * If the GstValueArray->values array is NULL, it will be created by the function.
- * The type of the values in the array are the same as the property's type.
+ * Gets a number of values for the given controllered property starting at the
+ * requested time. The array @values need to hold enough space for @n_values of
+ * the same type as the objects property's type.
*
- * The g_object_* functions are just convenience functions for GObject
+ * This function is useful if one wants to e.g. draw a graph of the control
+ * curve or apply a control curve sample by sample.
*
- * Returns: %TRUE if the given array(s) could be filled, %FALSE otherwise
+ * Returns: %TRUE if the given array could be filled, %FALSE otherwise
*/
gboolean
-gst_object_get_value_array (GstObject * object, GstClockTime timestamp,
- GstValueArray * value_array)
+gst_object_get_value_array (GstObject * object, const gchar * property_name,
+ GstClockTime timestamp, GstClockTime interval, guint n_values,
+ gpointer * values)
{
gboolean res = FALSE;
GstControlledProperty *prop;
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
+ g_return_val_if_fail (property_name, FALSE);
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
- g_return_val_if_fail (value_array, FALSE);
- g_return_val_if_fail (value_array->property_name, FALSE);
- g_return_val_if_fail (value_array->values, FALSE);
+ g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (interval), FALSE);
+ g_return_val_if_fail (values, FALSE);
GST_OBJECT_LOCK (object);
- if ((prop = gst_object_find_controlled_property (object,
- value_array->property_name))) {
+ if ((prop = gst_object_find_controlled_property (object, property_name))) {
res = gst_control_source_get_value_array (prop->csource, timestamp,
- value_array);
+ interval, n_values, values);
}
GST_OBJECT_UNLOCK (object);
return res;
GValue * gst_object_get_value (GstObject * object, const gchar * property_name,
GstClockTime timestamp);
-gboolean gst_object_get_value_array (GstObject * object, GstClockTime timestamp,
- GstValueArray * value_array);
+gboolean gst_object_get_value_array (GstObject * object, const gchar * property_name,
+ GstClockTime timestamp, GstClockTime interval,
+ guint n_values, gpointer *values);
GstClockTime gst_object_get_control_rate (GstObject * object);
void gst_object_set_control_rate (GstObject * object, GstClockTime control_rate);
\
static gboolean \
interpolate_none_get_##type##_value_array (GstInterpolationControlSource *self, \
- GstClockTime timestamp, GstValueArray * value_array) \
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *_values) \
{ \
- gint i; \
+ guint i; \
GstClockTime ts = timestamp; \
GstClockTime next_ts = 0; \
- ctype *values = (ctype *) value_array->values; \
+ ctype *values = (ctype *) _values; \
const GValue *ret_val = NULL; \
ctype ret = 0; \
GSequenceIter *iter1 = NULL, *iter2 = NULL; \
\
g_mutex_lock (self->lock); \
- for(i = 0; i < value_array->nbsamples; i++) { \
+ for(i = 0; i < n_values; i++) { \
if (!ret_val || ts >= next_ts) { \
iter1 = gst_interpolation_control_source_find_control_point_iter (self, ts); \
if (!iter1) { \
ret = g_value_get_##type (ret_val); \
} \
*values = ret; \
- ts += value_array->sample_interval; \
+ ts += interval; \
values++; \
} \
g_mutex_unlock (self->lock); \
\
static gboolean \
interpolate_trigger_get_##type##_value_array (GstInterpolationControlSource *self, \
- GstClockTime timestamp, GstValueArray * value_array) \
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *_values) \
{ \
- gint i; \
+ guint i; \
GstClockTime ts = timestamp; \
GstClockTime next_ts = 0; \
- ctype *values = (ctype *) value_array->values; \
+ ctype *values = (ctype *) _values; \
const GValue *ret_val = NULL; \
ctype ret = 0; \
GSequenceIter *iter1 = NULL, *iter2 = NULL; \
gboolean triggered = FALSE; \
\
g_mutex_lock (self->lock); \
- for(i = 0; i < value_array->nbsamples; i++) { \
+ for(i = 0; i < n_values; i++) { \
if (!ret_val || ts >= next_ts) { \
iter1 = gst_interpolation_control_source_find_control_point_iter (self, ts); \
if (!iter1) { \
triggered = FALSE; \
} \
*values = ret; \
- ts += value_array->sample_interval; \
+ ts += interval; \
values++; \
} \
g_mutex_unlock (self->lock); \
\
static gboolean \
interpolate_linear_get_##vtype##_value_array (GstInterpolationControlSource *self, \
- GstClockTime timestamp, GstValueArray * value_array) \
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *_values) \
{ \
- gint i; \
+ guint i; \
GstClockTime ts = timestamp; \
GstClockTime next_ts = 0; \
- g##vtype *values = (g##vtype *) value_array->values; \
+ g##vtype *values = (g##vtype *) _values; \
GSequenceIter *iter1, *iter2 = NULL; \
GstControlPoint *cp1 = NULL, *cp2 = NULL, cp = {0, }; \
g##vtype val1 = 0, val2 = 0, min, max; \
min = g_value_get_##vtype (&self->priv->minimum_value); \
max = g_value_get_##vtype (&self->priv->maximum_value); \
\
- for(i = 0; i < value_array->nbsamples; i++) { \
+ for(i = 0; i < n_values; i++) { \
if (timestamp >= next_ts) { \
iter1 = gst_interpolation_control_source_find_control_point_iter (self, ts); \
if (!iter1) { \
val2 = g_value_get_##vtype (&cp2->value); \
} \
_interpolate_linear_internal_##vtype (cp1->timestamp, val1, (cp2 ? cp2->timestamp : GST_CLOCK_TIME_NONE), (cp2 ? val2 : 0), ts, min, max, values); \
- ts += value_array->sample_interval; \
+ ts += interval; \
values++; \
} \
g_mutex_unlock (self->lock); \
\
static gboolean \
interpolate_cubic_get_##vtype##_value_array (GstInterpolationControlSource *self, \
- GstClockTime timestamp, GstValueArray * value_array) \
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *_values) \
{ \
- gint i; \
+ guint i; \
GstClockTime ts = timestamp; \
GstClockTime next_ts = 0; \
- g##vtype *values = (g##vtype *) value_array->values; \
+ g##vtype *values = (g##vtype *) _values; \
GSequenceIter *iter1, *iter2 = NULL; \
GstControlPoint *cp1 = NULL, *cp2 = NULL, cp = {0, }; \
g##vtype val1 = 0, val2 = 0, min, max; \
\
if (self->priv->nvalues <= 2) \
- return interpolate_linear_get_##vtype##_value_array (self, timestamp, value_array); \
+ return interpolate_linear_get_##vtype##_value_array (self, timestamp, interval, n_values, values); \
\
g_mutex_lock (self->lock); \
\
min = g_value_get_##vtype (&self->priv->minimum_value); \
max = g_value_get_##vtype (&self->priv->maximum_value); \
\
- for(i = 0; i < value_array->nbsamples; i++) { \
+ for(i = 0; i < n_values; i++) { \
if (timestamp >= next_ts) { \
iter1 = gst_interpolation_control_source_find_control_point_iter (self, ts); \
if (!iter1) { \
val2 = g_value_get_##vtype (&cp2->value); \
} \
_interpolate_cubic_get_##vtype (self, cp1, val1, cp2, val2, timestamp, min, max, values); \
- ts += value_array->sample_interval; \
+ ts += interval; \
values++; \
} \
g_mutex_unlock (self->lock); \
\
static gboolean \
waveform_sine_get_##type##_value_array (GstLFOControlSource *self, \
- GstClockTime timestamp, GstValueArray * value_array) \
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *_values) \
{ \
- gint i; \
+ guint i; \
GstClockTime ts = timestamp; \
- g##type *values = (g##type *) value_array->values; \
+ g##type *values = (g##type *) _values; \
g##type max, min; \
gdouble amp, off, frequency; \
GstClockTime timeshift, period; \
period = self->priv->period; \
frequency = self->priv->frequency; \
\
- for(i = 0; i < value_array->nbsamples; i++) { \
+ for(i = 0; i < n_values; i++) { \
*values = _sine_get_##type (self, max, min, amp, off, timeshift, period, frequency, ts); \
- ts += value_array->sample_interval; \
+ ts += interval; \
values++; \
} \
g_mutex_unlock (self->lock); \
\
static gboolean \
waveform_square_get_##type##_value_array (GstLFOControlSource *self, \
- GstClockTime timestamp, GstValueArray * value_array) \
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *_values) \
{ \
- gint i; \
+ guint i; \
GstClockTime ts = timestamp; \
- g##type *values = (g##type *) value_array->values; \
+ g##type *values = (g##type *) _values; \
g##type max, min; \
gdouble amp, off, frequency; \
GstClockTime timeshift, period; \
period = self->priv->period; \
frequency = self->priv->frequency; \
\
- for(i = 0; i < value_array->nbsamples; i++) { \
+ for(i = 0; i < n_values; i++) { \
*values = _square_get_##type (self, max, min, amp, off, timeshift, period, frequency, ts); \
- ts += value_array->sample_interval; \
+ ts += interval; \
values++; \
} \
g_mutex_unlock (self->lock); \
\
static gboolean \
waveform_saw_get_##type##_value_array (GstLFOControlSource *self, \
- GstClockTime timestamp, GstValueArray * value_array) \
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *_values) \
{ \
- gint i; \
+ guint i; \
GstClockTime ts = timestamp; \
- g##type *values = (g##type *) value_array->values; \
+ g##type *values = (g##type *) _values; \
g##type max, min; \
gdouble amp, off, frequency; \
GstClockTime timeshift, period; \
period = self->priv->period; \
frequency = self->priv->frequency; \
\
- for(i = 0; i < value_array->nbsamples; i++) { \
+ for(i = 0; i < n_values; i++) { \
*values = _saw_get_##type (self, max, min, amp, off, timeshift, period, frequency, ts); \
- ts += value_array->sample_interval; \
+ ts += interval; \
values++; \
} \
g_mutex_unlock (self->lock); \
\
static gboolean \
waveform_rsaw_get_##type##_value_array (GstLFOControlSource *self, \
- GstClockTime timestamp, GstValueArray * value_array) \
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *_values) \
{ \
- gint i; \
+ guint i; \
GstClockTime ts = timestamp; \
- g##type *values = (g##type *) value_array->values; \
+ g##type *values = (g##type *) _values; \
g##type max, min; \
gdouble amp, off, frequency; \
GstClockTime timeshift, period; \
period = self->priv->period; \
frequency = self->priv->frequency; \
\
- for(i = 0; i < value_array->nbsamples; i++) { \
+ for(i = 0; i < n_values; i++) { \
*values = _rsaw_get_##type (self, max, min, amp, off, timeshift, period, frequency, ts); \
- ts += value_array->sample_interval; \
+ ts += interval; \
values++; \
} \
g_mutex_unlock (self->lock); \
\
static gboolean \
waveform_triangle_get_##type##_value_array (GstLFOControlSource *self, \
- GstClockTime timestamp, GstValueArray * value_array) \
+ GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer *_values) \
{ \
- gint i; \
+ guint i; \
GstClockTime ts = timestamp; \
- g##type *values = (g##type *) value_array->values; \
+ g##type *values = (g##type *) _values; \
g##type max, min; \
gdouble amp, off, frequency; \
GstClockTime timeshift, period; \
period = self->priv->period; \
frequency = self->priv->frequency; \
\
- for(i = 0; i < value_array->nbsamples; i++) { \
+ for(i = 0; i < n_values; i++) { \
*values = _triangle_get_##type (self, max, min, amp, off, timeshift, period, frequency, ts); \
- ts += value_array->sample_interval; \
+ ts += interval; \
values++; \
} \
g_mutex_unlock (self->lock); \
{
GstClockTime sample_duration =
gst_util_uint64_scale_int (1, GST_SECOND, 44100);
- GstValueArray va = { "freq",
- BLOCK_SIZE * NUM_CP,
- sample_duration,
- NULL
- };
-
gdouble *values = g_new0 (gdouble, BLOCK_SIZE * NUM_CP);
- va.values = (gpointer *) values;
bt = gst_util_get_timestamp ();
- gst_control_source_get_value_array (GST_CONTROL_SOURCE (csource), 0, &va);
+ gst_control_source_get_value_array (GST_CONTROL_SOURCE (csource), 0,
+ sample_duration, BLOCK_SIZE * NUM_CP, (gpointer) values);
ct = gst_util_get_timestamp ();
g_free (values);
elapsed = GST_CLOCK_DIFF (bt, ct);