discoverer: Don't crash when running with -v if channel-mask==0 and >7 channels

For e.g. 16-channel audio, if the channel mask is 0 (which it usually
is), gst_audio_channel_positions_from_mask would get confused,
ultimately leading into a crash.

https://bugzilla.gnome.org/show_bug.cgi?id=796578
This commit is contained in:
Vivia Nikolaidou 2018-06-13 15:29:46 +03:00
parent 1208ef637a
commit effd892021

View file

@ -157,17 +157,23 @@ format_channel_mask (GstDiscovererAudioInfo * ainfo)
guint channels = gst_discoverer_audio_info_get_channels (ainfo);
GEnumClass *enum_class = g_type_class_ref (GST_TYPE_AUDIO_CHANNEL_POSITION);
guint i;
guint64 channel_mask;
if (channels == 0)
goto done;
gst_audio_channel_positions_from_mask (channels,
gst_discoverer_audio_info_get_channel_mask (ainfo), position);
channel_mask = gst_discoverer_audio_info_get_channel_mask (ainfo);
for (i = 0; i < channels; i++) {
GEnumValue *value = g_enum_get_value (enum_class, position[i]);
my_g_string_append_printf (s, 0, "%s%s", value->value_nick,
i + 1 == channels ? "" : ", ");
if (channel_mask != 0) {
gst_audio_channel_positions_from_mask (channels, channel_mask, position);
for (i = 0; i < channels; i++) {
GEnumValue *value = g_enum_get_value (enum_class, position[i]);
my_g_string_append_printf (s, 0, "%s%s", value->value_nick,
i + 1 == channels ? "" : ", ");
}
} else {
g_string_append (s, "unknown layout");
}
g_type_class_unref (enum_class);