mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Avoid crash when testing spatialization of high channel count audio
For audio with more than 12 channels, no channel mask was determined, which meant that the code to check spatializability would throw because of creating an invalid audio format. Return early if the channel mask was invalid instead (and assume spatialization isn't possible). PiperOrigin-RevId: 625618683
This commit is contained in:
parent
a58a99e84d
commit
2f8ce053b9
@ -4249,10 +4249,14 @@ public class DefaultTrackSelector extends MappingTrackSelector
|
||||
MimeTypes.AUDIO_E_AC3_JOC.equals(format.sampleMimeType) && format.channelCount == 16
|
||||
? 12
|
||||
: format.channelCount;
|
||||
int channelConfig = Util.getAudioTrackChannelConfig(linearChannelCount);
|
||||
if (channelConfig == AudioFormat.CHANNEL_INVALID) {
|
||||
return false;
|
||||
}
|
||||
AudioFormat.Builder builder =
|
||||
new AudioFormat.Builder()
|
||||
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
|
||||
.setChannelMask(Util.getAudioTrackChannelConfig(linearChannelCount));
|
||||
.setChannelMask(channelConfig);
|
||||
if (format.sampleRate != Format.NO_VALUE) {
|
||||
builder.setSampleRate(format.sampleRate);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user