Skip to content

Commit

Permalink
Update the TransformerMediaClock trackTime before deducting the offset.
Browse files Browse the repository at this point in the history
#minor-release

PiperOrigin-RevId: 407086818
  • Loading branch information
Samrobbo authored and tonihei committed Nov 3, 2021
1 parent 368f4d6 commit 5a98c82
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ private boolean feedDecoderFromInput(MediaCodecAdapterWrapper decoder) {
int result = readSource(getFormatHolder(), decoderInputBuffer, /* readFlags= */ 0);
switch (result) {
case C.RESULT_BUFFER_READ:
decoderInputBuffer.timeUs -= streamOffsetUs;
mediaClock.updateTimeForTrackType(getTrackType(), decoderInputBuffer.timeUs);
decoderInputBuffer.timeUs -= streamOffsetUs;
decoderInputBuffer.flip();
decoder.queueInputBuffer(decoderInputBuffer);
return !decoderInputBuffer.isEndOfStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public TransformerBaseRenderer(
}

@Override
protected void onStreamChanged(Format[] formats, long startPositionUs, long offsetUs)
throws ExoPlaybackException {
protected void onStreamChanged(Format[] formats, long startPositionUs, long offsetUs) {
this.streamOffsetUs = offsetUs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ private boolean readAndTransformBuffer() {
muxerWrapper.endTrack(getTrackType());
return false;
}
buffer.timeUs -= streamOffsetUs;
mediaClock.updateTimeForTrackType(getTrackType(), buffer.timeUs);
buffer.timeUs -= streamOffsetUs;
ByteBuffer data = checkNotNull(buffer.data);
data.flip();
if (sampleTransformer != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ private boolean feedDecoderFromInput(MediaCodecAdapterWrapper decoder) {
case C.RESULT_FORMAT_READ:
throw new IllegalStateException("Format changes are not supported.");
case C.RESULT_BUFFER_READ:
decoderInputBuffer.timeUs -= streamOffsetUs;
mediaClock.updateTimeForTrackType(getTrackType(), decoderInputBuffer.timeUs);
decoderInputBuffer.timeUs -= streamOffsetUs;
ByteBuffer data = checkNotNull(decoderInputBuffer.data);
data.flip();
decoder.queueInputBuffer(decoderInputBuffer);
Expand Down

0 comments on commit 5a98c82

Please sign in to comment.