From f573f028d2622c822d8e251b5034c8c83dd90781 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Tue, 9 Dec 2014 13:38:26 +0530 Subject: [PATCH] osxaudiosink: Add some error handling around channel layout parsing For now we just spit a warning and ignore the channel layout if we can't support it. https://bugzilla.gnome.org/show_bug.cgi?id=740987 --- sys/osxaudio/gstosxaudiosink.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sys/osxaudio/gstosxaudiosink.c b/sys/osxaudio/gstosxaudiosink.c index fffaf4e..8299800 100644 --- a/sys/osxaudio/gstosxaudiosink.c +++ b/sys/osxaudio/gstosxaudiosink.c @@ -632,6 +632,10 @@ gst_osx_audio_sink_probe_caps (GstOsxAudioSink * osxsink) g_free (layout); + if (!gst_audio_channel_positions_to_mask (pos, channels, TRUE, &channel_mask)) { + GST_WARNING_OBJECT (osxsink, "Probably unsupported channel order"); + } + /* Recover the template caps */ element_class = GST_ELEMENT_GET_CLASS (osxsink); pad_template = gst_element_class_get_pad_template (element_class, "sink"); @@ -650,11 +654,17 @@ gst_osx_audio_sink_probe_caps (GstOsxAudioSink * osxsink) gst_caps_append_structure (caps, gst_structure_copy (in_s)); } } else { - gst_audio_channel_positions_to_mask (pos, channels, false, &channel_mask); out_s = gst_structure_copy (in_s); - gst_structure_remove_fields (out_s, "channels", "channel-mask", NULL); - gst_structure_set (out_s, "channels", G_TYPE_INT, channels, - "channel-mask", GST_TYPE_BITMASK, channel_mask, NULL); + + gst_structure_remove_fields (out_s, "channels", NULL); + gst_structure_set (out_s, "channels", G_TYPE_INT, channels, NULL); + + if (channel_mask) { + gst_structure_remove_fields (out_s, "channel-mask", NULL); + gst_structure_set (out_s, "channel-mask", GST_TYPE_BITMASK, + channel_mask, NULL); + } + gst_caps_append_structure (caps, out_s); } } -- 2.7.4