Reworded comment and formatting fixes

This commit is contained in:
tonihei 2024-01-31 12:32:20 +00:00
parent 460280556e
commit 9ba93d386d
2 changed files with 7 additions and 14 deletions

View file

@ -76,7 +76,6 @@ import java.lang.annotation.Target;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.Objects;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.RequiresNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@ -767,16 +766,12 @@ public final class DefaultAudioSink implements AudioSink {
inputFormat); inputFormat);
} }
// For HLS-fMP4 and HLS-TS, the bit-rate of the DTS Express stream is not in the // Replace unknown bitrate by maximum allowed bitrate for DTS Express to avoid allocating an
// manifest file. The bit-rate has no value at the point of AudioTrack Initialisation. // AudioTrack buffer for the much larger maximum bitrate of the underlying DTS-HD encoding.
// This will lead to a computed direct passthrough playback buffer size of 2250000 int bitrate = inputFormat.bitrate;
// bytes. Some TVs (E.g. Xiaomi A Pro and Q2) do not support such a big buffer for if (MimeTypes.AUDIO_DTS_EXPRESS.equals(inputFormat.sampleMimeType)
// direct passthrough playback. It will crash at the point of AudioTrack Initialisation. && bitrate == Format.NO_VALUE) {
// Here we set the unknown bit-rate to a known peak bit-rate for DTS Express streams. bitrate = DtsUtil.DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND;
int bitRate = inputFormat.bitrate;
if (Objects.equals(inputFormat.sampleMimeType, MimeTypes.AUDIO_DTS_EXPRESS)
&& (inputFormat.bitrate == Format.NO_VALUE)) {
bitRate = DtsUtil.DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND;
} }
int bufferSize = int bufferSize =
@ -788,7 +783,7 @@ public final class DefaultAudioSink implements AudioSink {
outputMode, outputMode,
outputPcmFrameSize != C.LENGTH_UNSET ? outputPcmFrameSize : 1, outputPcmFrameSize != C.LENGTH_UNSET ? outputPcmFrameSize : 1,
outputSampleRate, outputSampleRate,
bitRate, bitrate,
enableAudioTrackPlaybackParams ? MAX_PLAYBACK_SPEED : DEFAULT_PLAYBACK_SPEED); enableAudioTrackPlaybackParams ? MAX_PLAYBACK_SPEED : DEFAULT_PLAYBACK_SPEED);
offloadDisabledUntilNextConfiguration = false; offloadDisabledUntilNextConfiguration = false;
Configuration pendingConfiguration = Configuration pendingConfiguration =

View file

@ -15,7 +15,6 @@
*/ */
package androidx.media3.exoplayer.mediacodec; package androidx.media3.exoplayer.mediacodec;
import static androidx.media3.common.Format.NO_VALUE;
import static androidx.media3.common.util.Assertions.checkNotNull; import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState; import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.common.util.Assertions.checkStateNotNull; import static androidx.media3.common.util.Assertions.checkStateNotNull;
@ -80,7 +79,6 @@ import androidx.media3.exoplayer.source.MediaSource;
import androidx.media3.exoplayer.source.SampleStream; import androidx.media3.exoplayer.source.SampleStream;
import androidx.media3.exoplayer.source.SampleStream.ReadDataResult; import androidx.media3.exoplayer.source.SampleStream.ReadDataResult;
import androidx.media3.exoplayer.source.SampleStream.ReadFlags; import androidx.media3.exoplayer.source.SampleStream.ReadFlags;
import androidx.media3.extractor.DtsUtil;
import androidx.media3.extractor.OpusUtil; import androidx.media3.extractor.OpusUtil;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;