audiomixmatrix: Remove property matrix-value-array

This duplicated property is no longer needed as there is now API to
allow bindings access GST_TYPE_ARRAY (see gst_util_get/set/object_array).
Additionnally, Python has proper overrides which will make this looks
like Python. A 2x2 matrix would be set this way:

  element = matrix = Gst.ValueArray(Gst.ValueArray([1.0, -1.0]),
      Gst.ValueArray([1.0, -1.0))

Notice that you need to "cast" each arrays to Gst.ValueArray, otherwise
there is an ambiguity between Gst.ValueArray and Gst.ValueList list type.
Fortunatly, Gst.ValueArray implements the Sequence interface, so it can
be indexed like normal python matrix.
This commit is contained in:
Nicolas Dufresne 2017-03-27 13:34:19 -04:00
parent 0a25fe2893
commit 18917de956

View file

@ -68,10 +68,6 @@
#include "config.h"
#endif
/* FIXME 2.0: suppress warnings for deprecated API such as GValueArray
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include "gstaudiomixmatrix.h"
#include <gst/gst.h>
@ -89,7 +85,6 @@ enum
PROP_IN_CHANNELS,
PROP_OUT_CHANNELS,
PROP_MATRIX,
PROP_MATRIX_VALUE_ARRAY,
PROP_CHANNEL_MASK,
PROP_MODE
};
@ -194,16 +189,6 @@ gst_audio_mix_matrix_class_init (GstAudioMixMatrixClass * klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_MATRIX_VALUE_ARRAY,
g_param_spec_value_array ("matrix-value-array",
"Input/output channel matrix (GValueArray)",
"Transformation matrix (GValueArray) for input/output channels",
g_param_spec_value_array ("matrix-va-in1", "rows", "rows",
g_param_spec_double ("matrix-va-in2", "cols", "cols",
-1, 1, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_CHANNEL_MASK,
g_param_spec_uint64 ("channel-mask",
"Output channel mask",
@ -343,35 +328,6 @@ gst_audio_mix_matrix_set_property (GObject * object, guint prop_id,
gst_audio_mix_matrix_convert_s32_matrix (self);
break;
}
case PROP_MATRIX_VALUE_ARRAY:{
gint in, out;
GValueArray *a;
if (self->matrix)
g_free (self->matrix);
self->matrix = g_new (gdouble, self->in_channels * self->out_channels);
a = g_value_get_boxed (value);
g_return_if_fail (a->n_values == self->out_channels);
for (out = 0; out < self->out_channels; out++) {
const GValue *row = g_value_array_get_nth (a, out);
GValueArray *ra = g_value_get_boxed (row);
g_return_if_fail (ra->n_values == self->in_channels);
for (in = 0; in < self->in_channels; in++) {
const GValue *itm;
gdouble coefficient;
itm = g_value_array_get_nth (ra, in);
g_return_if_fail (G_VALUE_HOLDS_DOUBLE (itm));
coefficient = g_value_get_double (itm);
self->matrix[out * self->in_channels + in] = coefficient;
}
}
gst_audio_mix_matrix_convert_s16_matrix (self);
gst_audio_mix_matrix_convert_s32_matrix (self);
break;
}
case PROP_CHANNEL_MASK:
self->channel_mask = g_value_get_uint64 (value);
break;
@ -415,29 +371,6 @@ gst_audio_mix_matrix_get_property (GObject * object, guint prop_id,
}
break;
}
case PROP_MATRIX_VALUE_ARRAY:{
gint in, out;
GValueArray *a = g_value_array_new (self->out_channels);
for (out = 0; out < self->out_channels; out++) {
GValue row = G_VALUE_INIT;
GValueArray *ra = g_value_array_new (self->in_channels);
g_value_init (&row, G_TYPE_VALUE_ARRAY);
for (in = 0; in < self->in_channels; in++) {
GValue itm = G_VALUE_INIT;
g_value_init (&itm, G_TYPE_DOUBLE);
g_value_set_double (&itm, self->matrix[out * self->in_channels + in]);
g_value_array_append (ra, &itm);
g_value_unset (&itm);
}
g_value_take_boxed (&row, ra);
g_value_array_append (a, &row);
g_value_unset (&row);
}
g_value_take_boxed (value, a);
break;
}
case PROP_CHANNEL_MASK:
g_value_set_uint64 (value, self->channel_mask);
break;