mirror of
https://github.com/samsonjs/media.git
synced 2026-03-31 10:25:48 +00:00
Remove old workaround for timestamp jumps
This workaround was added for TS streams that do not adjust their timestamps to start from zero. Over time, the default audio sink logic has become more robust towards unexpected timestamps and we no longer need this workaround to jump forward in time. The workaround also actively caused issues by adjusting the audio timestamps backwards if the stream starts with large negative values. See Issue: androidx/media#291. This caused playback to get stuck due to another bug in the first-frame rendering logic in the video renderer that is now fixed. PiperOrigin-RevId: 553493618
This commit is contained in:
parent
a3c1d5be9d
commit
57f327840b
2 changed files with 0 additions and 40 deletions
|
|
@ -158,7 +158,6 @@ public abstract class DecoderAudioRenderer<
|
|||
private boolean audioTrackNeedsConfigure;
|
||||
|
||||
private long currentPositionUs;
|
||||
private boolean allowFirstBufferPositionDiscontinuity;
|
||||
private boolean allowPositionDiscontinuity;
|
||||
private boolean inputStreamEnded;
|
||||
private boolean outputStreamEnded;
|
||||
|
|
@ -528,7 +527,6 @@ public abstract class DecoderAudioRenderer<
|
|||
}
|
||||
inputBuffer.flip();
|
||||
inputBuffer.format = inputFormat;
|
||||
onQueueInputBuffer(inputBuffer);
|
||||
decoder.queueInputBuffer(inputBuffer);
|
||||
decoderReceivedBuffers = true;
|
||||
decoderCounters.queuedInputBufferCount++;
|
||||
|
|
@ -611,7 +609,6 @@ public abstract class DecoderAudioRenderer<
|
|||
}
|
||||
|
||||
currentPositionUs = positionUs;
|
||||
allowFirstBufferPositionDiscontinuity = true;
|
||||
allowPositionDiscontinuity = true;
|
||||
inputStreamEnded = false;
|
||||
outputStreamEnded = false;
|
||||
|
|
@ -812,18 +809,6 @@ public abstract class DecoderAudioRenderer<
|
|||
eventDispatcher.inputFormatChanged(inputFormat, evaluation);
|
||||
}
|
||||
|
||||
protected void onQueueInputBuffer(DecoderInputBuffer buffer) {
|
||||
if (allowFirstBufferPositionDiscontinuity && !buffer.isDecodeOnly()) {
|
||||
// TODO: Remove this hack once we have a proper fix for [Internal: b/71876314].
|
||||
// Allow the position to jump if the first presentable input buffer has a timestamp that
|
||||
// differs significantly from what was expected.
|
||||
if (Math.abs(buffer.timeUs - currentPositionUs) > 500000) {
|
||||
currentPositionUs = buffer.timeUs;
|
||||
}
|
||||
allowFirstBufferPositionDiscontinuity = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCurrentPosition() {
|
||||
long newCurrentPositionUs = audioSink.getCurrentPositionUs(isEnded());
|
||||
if (newCurrentPositionUs != AudioSink.CURRENT_POSITION_NOT_SET) {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ import androidx.media3.common.util.Log;
|
|||
import androidx.media3.common.util.MediaFormatUtil;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.decoder.DecoderInputBuffer;
|
||||
import androidx.media3.exoplayer.DecoderReuseEvaluation;
|
||||
import androidx.media3.exoplayer.DecoderReuseEvaluation.DecoderDiscardReasons;
|
||||
import androidx.media3.exoplayer.ExoPlaybackException;
|
||||
|
|
@ -112,7 +111,6 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||
@Nullable private Format decryptOnlyCodecFormat;
|
||||
|
||||
private long currentPositionUs;
|
||||
private boolean allowFirstBufferPositionDiscontinuity;
|
||||
private boolean allowPositionDiscontinuity;
|
||||
private boolean audioSinkNeedsReset;
|
||||
|
||||
|
|
@ -624,7 +622,6 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||
}
|
||||
|
||||
currentPositionUs = positionUs;
|
||||
allowFirstBufferPositionDiscontinuity = true;
|
||||
allowPositionDiscontinuity = true;
|
||||
}
|
||||
|
||||
|
|
@ -701,28 +698,6 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||
return audioSink.getPlaybackParameters();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onQueueInputBuffer(DecoderInputBuffer buffer) {
|
||||
if (allowFirstBufferPositionDiscontinuity && !buffer.isDecodeOnly()) {
|
||||
// TODO: Remove this hack once we have a proper fix for [Internal: b/71876314].
|
||||
// Allow the position to jump if the first presentable input buffer has a timestamp that
|
||||
// differs significantly from what was expected.
|
||||
if (Math.abs(buffer.timeUs - currentPositionUs) > 500000) {
|
||||
currentPositionUs = buffer.timeUs;
|
||||
}
|
||||
allowFirstBufferPositionDiscontinuity = false;
|
||||
}
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
protected void onProcessedOutputBuffer(long presentationTimeUs) {
|
||||
super.onProcessedOutputBuffer(presentationTimeUs);
|
||||
// An output buffer has been successfully processed. If this value is not set to false then
|
||||
// onQueueInputBuffer on transition from offload to codec-based playback may occur early.
|
||||
allowFirstBufferPositionDiscontinuity = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProcessedStreamChange() {
|
||||
super.onProcessedStreamChange();
|
||||
|
|
|
|||
Loading…
Reference in a new issue