Configure MediaCodec in API 32+ to always output 99 channels

Configure MediaCodec in API 32+ to always output 99 channels
so that we use the audio is spatialized, if the platform can apply
spatialization to it.

In a follow-up change, the output channel count will be set based on the
device's spatialization capabilities.

PiperOrigin-RevId: 414751543
This commit is contained in:
christosts 2021-12-07 17:42:27 +00:00 committed by Ian Baker
parent 341bb57498
commit 87510592bb

View File

@ -795,6 +795,14 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
== AudioSink.SINK_FORMAT_SUPPORTED_DIRECTLY) { == AudioSink.SINK_FORMAT_SUPPORTED_DIRECTLY) {
mediaFormat.setInteger(MediaFormat.KEY_PCM_ENCODING, AudioFormat.ENCODING_PCM_FLOAT); mediaFormat.setInteger(MediaFormat.KEY_PCM_ENCODING, AudioFormat.ENCODING_PCM_FLOAT);
} }
if (Util.SDK_INT >= 32) {
// Disable down-mixing in the decoder (for decoders that read the max-output-channel-count
// key).
// TODO[b/190759307]: Update key to use MediaFormat.KEY_MAX_OUTPUT_CHANNEL_COUNT once the
// compile SDK target is set to 32.
mediaFormat.setInteger("max-output-channel-count", 99);
}
return mediaFormat; return mediaFormat;
} }