audio: Make sure 'channels' and 'channel-positions' are coherent

If channel-positions are present, check they match the reported
'channels' value.
This commit is contained in:
Edward Hervey 2011-10-05 11:57:54 +02:00
parent 70d967da7c
commit b8219faa90

View file

@ -345,9 +345,13 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps)
gst_audio_info_set_format (info, format, rate, channels);
pos_val_arr = gst_structure_get_value (str, "channel-positions");
if (pos_val_arr) {
guint max_pos = MIN (channels, 64);
if (channels != gst_value_array_get_size (pos_val_arr))
goto incoherent_channels;
for (i = 0; i < max_pos; i++) {
pos_val_entry = gst_value_array_get_value (pos_val_arr, i);
info->position[i] = g_value_get_enum (pos_val_entry);
@ -385,6 +389,13 @@ no_channels:
GST_ERROR ("no channels property given");
return FALSE;
}
incoherent_channels:
{
GST_ERROR ("There should be %d channels positions, but %d are present",
channels, gst_value_array_get_size (pos_val_arr));
return FALSE;
}
}
/**