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:
parent
70d967da7c
commit
b8219faa90
@ -345,9 +345,13 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps)
|
|||||||
gst_audio_info_set_format (info, format, rate, channels);
|
gst_audio_info_set_format (info, format, rate, channels);
|
||||||
|
|
||||||
pos_val_arr = gst_structure_get_value (str, "channel-positions");
|
pos_val_arr = gst_structure_get_value (str, "channel-positions");
|
||||||
|
|
||||||
if (pos_val_arr) {
|
if (pos_val_arr) {
|
||||||
guint max_pos = MIN (channels, 64);
|
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++) {
|
for (i = 0; i < max_pos; i++) {
|
||||||
pos_val_entry = gst_value_array_get_value (pos_val_arr, i);
|
pos_val_entry = gst_value_array_get_value (pos_val_arr, i);
|
||||||
info->position[i] = g_value_get_enum (pos_val_entry);
|
info->position[i] = g_value_get_enum (pos_val_entry);
|
||||||
@ -385,6 +389,13 @@ no_channels:
|
|||||||
GST_ERROR ("no channels property given");
|
GST_ERROR ("no channels property given");
|
||||||
return FALSE;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user