From a03f70e3cd6d89853c839038ad9da9d216e504d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 11 Jan 2012 10:44:37 +0100 Subject: [PATCH] audio: Add validity check for the UNPOSITIONED audio flag Also reset the flag when parsing caps. --- gst-libs/gst/audio/audio.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/audio/audio.c b/gst-libs/gst/audio/audio.c index b6b0679..2075373 100644 --- a/gst-libs/gst/audio/audio.c +++ b/gst-libs/gst/audio/audio.c @@ -529,6 +529,8 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps) GST_DEBUG ("parsing caps %" GST_PTR_FORMAT, caps); + info->flags = 0; + str = gst_caps_get_structure (caps, 0); if (!gst_structure_has_name (str, "audio/x-raw")) @@ -654,6 +656,7 @@ gst_audio_info_to_caps (const GstAudioInfo * info) GstCaps *caps; const gchar *format; const gchar *layout; + GstAudioFlags flags; g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (info->finfo != NULL, NULL); @@ -669,6 +672,13 @@ gst_audio_info_to_caps (const GstAudioInfo * info) else g_return_val_if_reached (NULL); + flags = info->flags; + if ((flags & GST_AUDIO_FLAG_UNPOSITIONED) && info->channels > 1 + && info->position[0] != GST_AUDIO_CHANNEL_POSITION_NONE) { + flags &= ~GST_AUDIO_FLAG_UNPOSITIONED; + GST_WARNING ("Unpositioned flag set but channel positions present"); + } + caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, format, "layout", G_TYPE_STRING, layout, @@ -679,7 +689,7 @@ gst_audio_info_to_caps (const GstAudioInfo * info) || info->position[0] != GST_AUDIO_CHANNEL_POSITION_MONO) { guint64 channel_mask = 0; - if ((info->flags & GST_AUDIO_FLAG_UNPOSITIONED)) { + if ((flags & GST_AUDIO_FLAG_UNPOSITIONED)) { channel_mask = 0; } else { if (!check_valid_channel_positions (info->position, info->channels, -- 2.7.4