mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Set valid channel masks for 8 and 12 channels on all Android versions
Util.getAudioTrackChannelConfig() maps a channel count to a channel mask that is passed to AudioTrack. The method expected that playback of 8-channel audio is possible from Android 5.1 and playback of 12-channel audio is only possible from Android 12L. However, there is no restriction on the upper number of channels that can be passed to the AudioTrack. google/ExoPlayer#10701 is an example where the audio decoder outputs 12 channels on an Android 10. This change removes the restrictions for 8 and 12 channels. Note, we still do not support playback of arbitrary number of channels as it would require further changes to DefaultAudioSink. #minor-release Issue: google/ExoPlayer#10701 PiperOrigin-RevId: 488659831 (cherry picked from commit 491b13622e79f5c2ef84771b1a29e40f47aca653)
This commit is contained in:
parent
dab5b3c152
commit
c22c2bf0c0
@ -52,6 +52,9 @@ Release notes
|
||||
output device ([#135](https://github.com/androidx/media/issues/135)).
|
||||
* Rename `androidx.media3.exoplayer.audio.AudioProcessor` to
|
||||
`androidx.media3.common.audio.AudioProcessor`.
|
||||
* Map 8-channel and 12-channel audio to the 7.1 and 7.1.4 channel masks
|
||||
respectively on all Android versions
|
||||
([#10701](https://github.com/google/ExoPlayer/issues/10701)).
|
||||
* Metadata:
|
||||
* `MetadataRenderer` can now be configured to render metadata as soon as
|
||||
they are available. Create an instance with
|
||||
|
@ -1861,6 +1861,7 @@ public final class Util {
|
||||
* @return The channel configuration or {@link AudioFormat#CHANNEL_INVALID} if output is not
|
||||
* possible.
|
||||
*/
|
||||
@SuppressLint("InlinedApi") // Inlined AudioFormat constants.
|
||||
@UnstableApi
|
||||
public static int getAudioTrackChannelConfig(int channelCount) {
|
||||
switch (channelCount) {
|
||||
@ -1879,21 +1880,9 @@ public final class Util {
|
||||
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;
|
||||
}
|
||||
|
@ -771,16 +771,6 @@ public final class DefaultAudioSink implements AudioSink {
|
||||
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(
|
||||
@ -791,6 +781,16 @@ public final class DefaultAudioSink implements AudioSink {
|
||||
"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 =
|
||||
|
Loading…
x
Reference in New Issue
Block a user