diff options
author | Josep Torra <jtorra@oblong.com> | 2017-05-20 17:09:52 +0200 |
---|---|---|
committer | Josep Torra <jtorra@oblong.com> | 2017-05-20 18:33:42 +0200 |
commit | d699dc615ee629e64180be685c7b068b5b7ffa12 (patch) | |
tree | dc44d72ececea7c9af8c08e60b5f628cf99928d6 | |
parent | de3e54690bc5b37961c166352ad10d77d06968aa (diff) |
osxaudio: fixes playback of mono streams with no channel-mask field in caps
Fixes a negotiation error seen when trying to playback of a .MOV file with
a mono AAC audio stream decoded by avcdec_aac that doesn't set channel-mask
field but sink was requiring channel-mask=0x3.
-rw-r--r-- | sys/osxaudio/gstosxcoreaudio.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/sys/osxaudio/gstosxcoreaudio.c b/sys/osxaudio/gstosxcoreaudio.c index d516e6d20..5d3b882d9 100644 --- a/sys/osxaudio/gstosxcoreaudio.c +++ b/sys/osxaudio/gstosxcoreaudio.c @@ -644,24 +644,33 @@ gst_core_audio_probe_caps (GstCoreAudio * core_audio, GstCaps * in_caps) * e.g. if you push 5.1-surround audio to a stereo configuration, * the left and right channels will be played accordingly, * and the rest will be dropped. */ - - if (channels == 1 || (channels == 2 && - (channel_mask == 0 || channel_mask == STEREO_CHANNEL_MASK))) { - + if (channels == 1) { + /* If have mono, then also offer stereo since CoreAudio downmixes to it */ + GstStructure *stereo = gst_structure_copy (out_s); + gst_structure_remove_field (out_s, "channel-mask"); + gst_structure_set (stereo, "channels", G_TYPE_INT, 2, + "channel-mask", GST_TYPE_BITMASK, STEREO_CHANNEL_MASK, NULL); + gst_caps_append_structure (caps, stereo); + gst_caps_append_structure (caps, out_s); + } else if (channels == 2 && (channel_mask == 0 + || channel_mask == STEREO_CHANNEL_MASK)) { /* If have stereo channels, then also offer mono since CoreAudio - * upmixes it. If mono, then also offer stereo since CoreAudio - * downmixes to it */ - - gst_structure_set (out_s, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL); - - if (channels == 1) - gst_structure_set (out_s, "channel-mask", GST_TYPE_BITMASK, - STEREO_CHANNEL_MASK, NULL); + * upmixes it. */ + GstStructure *mono = gst_structure_copy (out_s); + gst_structure_set (mono, "channels", G_TYPE_INT, 1, NULL); + gst_structure_remove_field (mono, "channel-mask"); + gst_structure_set (out_s, "channel-mask", GST_TYPE_BITMASK, + STEREO_CHANNEL_MASK, NULL); + + gst_caps_append_structure (caps, out_s); + gst_caps_append_structure (caps, mono); + } else { + /* Otherwhise just add the caps */ + gst_caps_append_structure (caps, out_s); } - - gst_caps_append_structure (caps, out_s); } } + GST_DEBUG_OBJECT (core_audio, "Probed caps:%" GST_PTR_FORMAT, caps); return caps; } |