mirror of
https://github.com/samsonjs/media.git
synced 2026-04-18 13:25:47 +00:00
Correctly update output info if previous stream has been fully rendered
The output info for a new stream is marked pending until the last
sample of the previous stream has been processed. However, this fails
if the previous stream has already been fully processed. We need to
detect this case explicitly to avoid signalling the output change one
sample too late.
#minor-release
PiperOrigin-RevId: 512572854
(cherry picked from commit 39935d7f12)
This commit is contained in:
parent
5862fe4d8c
commit
f5c696729c
1 changed files with 9 additions and 2 deletions
|
|
@ -356,6 +356,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
@Nullable private ExoPlaybackException pendingPlaybackException;
|
||||
protected DecoderCounters decoderCounters;
|
||||
private OutputStreamInfo outputStreamInfo;
|
||||
private long lastProcessedOutputBufferTimeUs;
|
||||
|
||||
/**
|
||||
* @param trackType The {@link C.TrackType track type} that the renderer handles.
|
||||
|
|
@ -406,6 +407,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
codecHotswapDeadlineMs = C.TIME_UNSET;
|
||||
largestQueuedPresentationTimeUs = C.TIME_UNSET;
|
||||
lastBufferInStreamPresentationTimeUs = C.TIME_UNSET;
|
||||
lastProcessedOutputBufferTimeUs = C.TIME_UNSET;
|
||||
codecDrainState = DRAIN_STATE_NONE;
|
||||
codecDrainAction = DRAIN_ACTION_NONE;
|
||||
}
|
||||
|
|
@ -635,8 +637,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
@Override
|
||||
protected void onStreamChanged(Format[] formats, long startPositionUs, long offsetUs)
|
||||
throws ExoPlaybackException {
|
||||
if (outputStreamInfo.streamOffsetUs == C.TIME_UNSET) {
|
||||
checkState(outputStreamInfo.startPositionUs == C.TIME_UNSET);
|
||||
if (outputStreamInfo.streamOffsetUs == C.TIME_UNSET
|
||||
|| (pendingOutputStreamChanges.isEmpty()
|
||||
&& lastProcessedOutputBufferTimeUs != C.TIME_UNSET
|
||||
&& lastProcessedOutputBufferTimeUs >= largestQueuedPresentationTimeUs)) {
|
||||
// This is the first stream, or the previous has been fully output already.
|
||||
setOutputStreamInfo(
|
||||
new OutputStreamInfo(
|
||||
/* previousStreamLastBufferTimeUs= */ C.TIME_UNSET, startPositionUs, offsetUs));
|
||||
|
|
@ -869,6 +874,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
decodeOnlyPresentationTimestamps.clear();
|
||||
largestQueuedPresentationTimeUs = C.TIME_UNSET;
|
||||
lastBufferInStreamPresentationTimeUs = C.TIME_UNSET;
|
||||
lastProcessedOutputBufferTimeUs = C.TIME_UNSET;
|
||||
if (c2Mp3TimestampTracker != null) {
|
||||
c2Mp3TimestampTracker.reset();
|
||||
}
|
||||
|
|
@ -1565,6 +1571,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
*/
|
||||
@CallSuper
|
||||
protected void onProcessedOutputBuffer(long presentationTimeUs) {
|
||||
lastProcessedOutputBufferTimeUs = presentationTimeUs;
|
||||
if (!pendingOutputStreamChanges.isEmpty()
|
||||
&& presentationTimeUs >= pendingOutputStreamChanges.peek().previousStreamLastBufferTimeUs) {
|
||||
setOutputStreamInfo(pendingOutputStreamChanges.poll());
|
||||
|
|
|
|||
Loading…
Reference in a new issue