From e5c598468e546f6603c20697cb56d5b4cf62c444 Mon Sep 17 00:00:00 2001 From: christosts Date: Tue, 7 Dec 2021 17:42:27 +0000 Subject: [PATCH] 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 --- .../android/exoplayer2/audio/MediaCodecAudioRenderer.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java index 3c27163466..c65f46b837 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java @@ -791,6 +791,14 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media == AudioSink.SINK_FORMAT_SUPPORTED_DIRECTLY) { 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; }