diff options
author | 2016-08-24 14:35:09 -0400 | |
---|---|---|
committer | 2016-08-24 16:59:16 -0400 | |
commit | db90897b5fa23aa46ce50494e0fb4808948f4524 (patch) | |
tree | 19edb488dd6fc2e0c8625d45e6cf54c6866092c6 | |
parent | edaaef304aa7e72ac3f8a0b586b5513fd4df0267 (diff) |
Support multichannel sounds in bootanim
Manually handle the 1-2 channel cases to avoid the warning
log when 0 is passed as the channelMask.
Bug: 30820152
Change-Id: I4d2c8736ff442fae9a4c5eb16061646fb53151b6
-rw-r--r-- | cmds/bootanimation/audioplay.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/cmds/bootanimation/audioplay.cpp b/cmds/bootanimation/audioplay.cpp index 4983b9ac4236..c546072e733a 100644 --- a/cmds/bootanimation/audioplay.cpp +++ b/cmds/bootanimation/audioplay.cpp @@ -141,13 +141,27 @@ bool createBufferQueueAudioPlayer(const ChunkFormat* chunkFormat) { // 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}; |