* </refsect2>
*/
-/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
- * with newer GLib versions (>= 2.31.0) */
-#define GLIB_DISABLE_DEPRECATION_WARNINGS
-
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
if (self->channel_positions
&& self->channel_positions != self->input_channel_positions) {
- g_array_free (self->channel_positions, TRUE);
+ g_value_array_free (self->channel_positions);
self->channel_positions = NULL;
}
if (self->input_channel_positions) {
- g_array_free (self->input_channel_positions, TRUE);
+ g_value_array_free (self->input_channel_positions);
self->input_channel_positions = NULL;
}
}
static gboolean
-gst_interleave_check_channel_positions (GArray * positions)
+gst_interleave_check_channel_positions (GValueArray * positions)
{
gint i;
guint channels;
GstAudioChannelPosition *pos;
gboolean ret;
- GValue val;
- channels = positions->len;
+ channels = positions->n_values;
pos = g_new (GstAudioChannelPosition, channels);
for (i = 0; i < channels; i++) {
- val = g_array_index (positions, GValue, i);
- pos[i] = g_value_get_enum (&val);
- g_value_reset (&val);
+ GValue *val;
+
+ val = g_value_array_get_nth (positions, i);
+ pos[i] = g_value_get_enum (val);
}
ret = gst_audio_check_valid_channel_positions (pos, channels, FALSE);
{
gint i;
guint64 channel_mask = 0;
- GValue val;
- if (self->channel_positions && self->channels == self->channel_positions->len
+ if (self->channel_positions != NULL &&
+ self->channels == self->channel_positions->n_values
&& gst_interleave_check_channel_positions (self->channel_positions)) {
GST_DEBUG_OBJECT (self, "Using provided channel positions");
for (i = 0; i < self->channels; i++) {
- val = g_array_index (self->channel_positions, GValue, i);
- channel_mask |= G_GUINT64_CONSTANT (1) << g_value_get_enum (&val);
- g_value_reset (&val);
+ GValue *val;
+
+ val = g_value_array_get_nth (self->channel_positions, i);
+ channel_mask |= G_GUINT64_CONSTANT (1) << g_value_get_enum (val);
}
} else {
GST_WARNING_OBJECT (self, "Using NONE channel positions");
*
*/
g_object_class_install_property (gobject_class, PROP_CHANNEL_POSITIONS,
- g_param_spec_boxed ("channel-positions", "Channel positions",
- "Channel position of the n-th output", G_TYPE_ARRAY,
+ g_param_spec_value_array ("channel-positions", "Channel positions",
+ "Channel positions used on the output",
+ g_param_spec_enum ("channel-position", "Channel position",
+ "Channel position of the n-th input",
+ GST_TYPE_AUDIO_CHANNEL_POSITION,
+ GST_AUDIO_CHANNEL_POSITION_NONE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
gst_collect_pads2_set_function (self->collect,
(GstCollectPads2Function) gst_interleave_collected, self);
- self->input_channel_positions = g_array_new (FALSE, TRUE, sizeof (GValue));
+ self->input_channel_positions = g_value_array_new (0);
self->channel_positions_from_input = TRUE;
self->channel_positions = self->input_channel_positions;
}
const GValue * value, GParamSpec * pspec)
{
GstInterleave *self = GST_INTERLEAVE (object);
- int i;
- GArray *arr;
switch (prop_id) {
case PROP_CHANNEL_POSITIONS:
if (self->channel_positions &&
self->channel_positions != self->input_channel_positions)
- g_array_free (self->channel_positions, TRUE);
+ g_value_array_free (self->channel_positions);
- arr = g_value_get_boxed (value);
- self->channel_positions = g_array_new (FALSE, TRUE, sizeof (GValue));
- for (i = 0; i < arr->len; i++)
- g_array_append_val (self->channel_positions, g_array_index (arr, GValue,
- i));
+ self->channel_positions = g_value_dup_boxed (value);
self->channel_positions_from_input = FALSE;
- self->channels = self->channel_positions->len;
+ self->channels = self->channel_positions->n_values;
break;
case PROP_CHANNEL_POSITIONS_FROM_INPUT:
self->channel_positions_from_input = g_value_get_boolean (value);
if (self->channel_positions_from_input) {
if (self->channel_positions &&
self->channel_positions != self->input_channel_positions)
- g_array_free (self->channel_positions, TRUE);
+ g_value_array_free (self->channel_positions);
self->channel_positions = self->input_channel_positions;
}
break;
g_value_init (&val, GST_TYPE_AUDIO_CHANNEL_POSITION);
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_NONE);
self->input_channel_positions =
- g_array_append_val (self->input_channel_positions, val);
+ g_value_array_append (self->input_channel_positions, &val);
g_value_unset (&val);
/* Update the src caps if we already have them */
g_atomic_int_add (&self->channels, -1);
position = GST_INTERLEAVE_PAD_CAST (pad)->channel;
- g_array_remove_index (self->input_channel_positions, position);
+ g_value_array_remove (self->input_channel_positions, position);
/* Update channel numbers */
GST_OBJECT_LOCK (self);
if (self->channel_positions_from_input
&& GST_AUDIO_INFO_CHANNELS (&info) == 1) {
- val = &g_array_index (self->input_channel_positions, GValue, channel);
+ val = g_value_array_get_nth (self->input_channel_positions, channel);
g_value_set_enum (val, GST_AUDIO_INFO_POSITION (&info, 0));
}
GstElement *pipeline, *queue, *src1, *src2, *interleave, *sink;
GstPad *sinkpad0, *sinkpad1, *tmp, *tmp2;
GstMessage *msg;
- GArray *arr;
+ GValueArray *arr;
GValue val = { 0, };
have_data = 0;
interleave = gst_element_factory_make ("interleave", "interleave");
fail_unless (interleave != NULL);
g_object_set (interleave, "channel-positions-from-input", FALSE, NULL);
- arr = g_array_new (FALSE, TRUE, sizeof (GValue));
+ arr = g_value_array_new (2);
g_value_init (&val, GST_TYPE_AUDIO_CHANNEL_POSITION);
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER);
- g_array_append_val (arr, val);
+ g_value_array_append (arr, &val);
g_value_reset (&val);
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER);
- g_array_append_val (arr, val);
+ g_value_array_append (arr, &val);
g_value_unset (&val);
g_object_set (interleave, "channel-positions", arr, NULL);
- g_array_free (arr, TRUE);
+ g_value_array_free (arr);
gst_bin_add (GST_BIN (pipeline), gst_object_ref (interleave));
sinkpad0 = gst_element_get_request_pad (interleave, "sink_%u");