AudioTrack: Do not throw exception from isMultichannelConfigSupported

Test: atest AudioTrackTest#testInvalidMinBufferSize
Bug: 200571916
Change-Id: I85f2cb2d6f3ba84ed93a505fc3eb35387bc8a5ce
This commit is contained in:
Richard Folke Tullberg
2021-10-13 10:25:09 -07:00
committed by Andy Hung
parent 31ecebec87
commit 4b8954d48b

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 + ")");