diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java index 0e9ac3dd5a4..315ffacc984 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java @@ -1779,6 +1779,7 @@ public static boolean isEncodingHighResolutionPcm(@C.PcmEncoding int encoding) { * @return The channel configuration or {@link AudioFormat#CHANNEL_INVALID} if output is not * possible. */ + @SuppressLint("InlinedApi") // Inlined AudioFormat constants. public static int getAudioTrackChannelConfig(int channelCount) { switch (channelCount) { case 1: @@ -1796,21 +1797,9 @@ public static int getAudioTrackChannelConfig(int channelCount) { case 7: return AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER; case 8: - if (SDK_INT >= 23) { - return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND; - } else if (SDK_INT >= 21) { - // Equal to AudioFormat.CHANNEL_OUT_7POINT1_SURROUND, which is hidden before Android M. - return AudioFormat.CHANNEL_OUT_5POINT1 - | AudioFormat.CHANNEL_OUT_SIDE_LEFT - | AudioFormat.CHANNEL_OUT_SIDE_RIGHT; - } else { - // 8 ch output is not supported before Android L. - return AudioFormat.CHANNEL_INVALID; - } + return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND; case 12: - return Util.SDK_INT >= 32 - ? AudioFormat.CHANNEL_OUT_7POINT1POINT4 - : AudioFormat.CHANNEL_INVALID; + return AudioFormat.CHANNEL_OUT_7POINT1POINT4; default: return AudioFormat.CHANNEL_INVALID; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java index 83475503282..e979060bd5f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java @@ -680,16 +680,6 @@ public void configure(Format inputFormat, int specifiedBufferSize, @Nullable int outputChannelConfig = encodingAndChannelConfig.second; } } - int bufferSize = - specifiedBufferSize != 0 - ? specifiedBufferSize - : audioTrackBufferSizeProvider.getBufferSizeInBytes( - getAudioTrackMinBufferSize(outputSampleRate, outputChannelConfig, outputEncoding), - outputEncoding, - outputMode, - outputPcmFrameSize, - outputSampleRate, - enableAudioTrackPlaybackParams ? MAX_PLAYBACK_SPEED : DEFAULT_PLAYBACK_SPEED); if (outputEncoding == C.ENCODING_INVALID) { throw new ConfigurationException( @@ -700,6 +690,16 @@ public void configure(Format inputFormat, int specifiedBufferSize, @Nullable int "Invalid output channel config (mode=" + outputMode + ") for: " + inputFormat, inputFormat); } + int bufferSize = + specifiedBufferSize != 0 + ? specifiedBufferSize + : audioTrackBufferSizeProvider.getBufferSizeInBytes( + getAudioTrackMinBufferSize(outputSampleRate, outputChannelConfig, outputEncoding), + outputEncoding, + outputMode, + outputPcmFrameSize, + outputSampleRate, + enableAudioTrackPlaybackParams ? MAX_PLAYBACK_SPEED : DEFAULT_PLAYBACK_SPEED); offloadDisabledUntilNextConfiguration = false; Configuration pendingConfiguration =