Bug 1432779 - P14. If a layout is unknown or invalid, always treat it as plain stereo or mono. r?padenot draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 15 Mar 2018 17:40:42 +0100
changeset 768211 322373f293a7a7ad52574cd83cf72d61540d3583
parent 768210 a996321bbc2b4aac49dfa539207efc5a50f8f5f7
push id102819
push userbmo:jyavenard@mozilla.com
push dateThu, 15 Mar 2018 19:46:59 +0000
reviewerspadenot
bugs1432779
milestone61.0a1
Bug 1432779 - P14. If a layout is unknown or invalid, always treat it as plain stereo or mono. r?padenot MozReview-Commit-ID: F9FhLJoP4BO
media/libcubeb/src/cubeb_mixer.cpp
--- a/media/libcubeb/src/cubeb_mixer.cpp
+++ b/media/libcubeb/src/cubeb_mixer.cpp
@@ -78,18 +78,28 @@ unsigned int cubeb_channel_layout_nb_cha
 }
 struct MixerContext {
   MixerContext(cubeb_sample_format f,
                uint32_t in_channels,
                cubeb_channel_layout in,
                uint32_t out_channels,
                cubeb_channel_layout out)
     : _format(f)
-    , _in_ch_layout(in)
-    , _out_ch_layout(out)
+    , _in_ch_layout(in == CUBEB_LAYOUT_UNDEFINED
+                      ? (in_channels == 1
+                           ? CUBEB_LAYOUT_MONO
+                           : (in_channels == 2 ? CUBEB_LAYOUT_STEREO
+                                               : CUBEB_LAYOUT_UNDEFINED))
+                      : in)
+    , _out_ch_layout(
+        (out == CUBEB_LAYOUT_UNDEFINED
+           ? (out_channels == 1 ? CUBEB_LAYOUT_MONO
+                                : (out_channels == 2 ? CUBEB_LAYOUT_STEREO
+                                                     : CUBEB_LAYOUT_UNDEFINED))
+           : out))
     , _in_ch_count(in_channels)
     , _out_ch_count(out_channels)
   {
     if (in_channels != cubeb_channel_layout_nb_channels(in) ||
         out_channels != cubeb_channel_layout_nb_channels(out)) {
       // Mismatch between channels and layout, aborting.
       return;
     }