Support multichannel sounds in bootanim
am: db90897b5f

Change-Id: Ied6b429e05d5d77c76e9bbf34a7f13104be8bb8e
diff --git a/cmds/bootanimation/audioplay.cpp b/cmds/bootanimation/audioplay.cpp
index 4983b9a..c546072 100644
--- a/cmds/bootanimation/audioplay.cpp
+++ b/cmds/bootanimation/audioplay.cpp
@@ -141,13 +141,27 @@
     // configure audio source
     SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 1};
 
+    // Determine channelMask from num_channels
+    SLuint32 channelMask;
+    switch (chunkFormat->num_channels) {
+        case 1:
+            channelMask = SL_SPEAKER_FRONT_CENTER;
+            break;
+        case 2:
+            channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
+            break;
+        default:
+            // Default of 0 will derive mask from num_channels and log a warning.
+            channelMask = 0;
+    }
+
     SLDataFormat_PCM format_pcm = {
         SL_DATAFORMAT_PCM,
         chunkFormat->num_channels,
         chunkFormat->sample_rate * 1000,  // convert to milliHz
         chunkFormat->bits_per_sample,
         16,
-        SL_SPEAKER_FRONT_CENTER,
+        channelMask,
         SL_BYTEORDER_LITTLEENDIAN
     };
     SLDataSource audioSrc = {&loc_bufq, &format_pcm};