Merge "AudioTrack: Do not throw exception from isMultichannelConfigSupported" into sc-v2-dev am: f3ca848003

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16047732

Change-Id: Ifa3e0c2475e8a5f44c5298e30af942eecf67c34b
This commit is contained in:
Andy Hung
2021-10-15 09:24:26 +00:00
committed by Automerger Merge Worker

View File

@@ -1805,9 +1805,15 @@ public class AudioTrack extends PlayerBase
return false;
}
final int channelCount = AudioFormat.channelCountFromOutChannelMask(channelConfig);
final int channelCountLimit = AudioFormat.isEncodingLinearFrames(encoding)
? AudioSystem.OUT_CHANNEL_COUNT_MAX // PCM limited to OUT_CHANNEL_COUNT_MAX
: AudioSystem.FCC_24; // Compressed limited to 24 channels
final int channelCountLimit;
try {
channelCountLimit = AudioFormat.isEncodingLinearFrames(encoding)
? AudioSystem.OUT_CHANNEL_COUNT_MAX // PCM limited to OUT_CHANNEL_COUNT_MAX
: AudioSystem.FCC_24; // Compressed limited to 24 channels
} catch (IllegalArgumentException iae) {
loge("Unsupported encoding " + iae);
return false;
}
if (channelCount > channelCountLimit) {
loge("Channel configuration contains too many channels for encoding "
+ encoding + "(" + channelCount + " > " + channelCountLimit + ")");