Skip to content

Commit

Permalink
Reset readingPositionUs in BaseRenderer.enable
Browse files Browse the repository at this point in the history
This does currently only happen by chance in replaceStream (called from
enable) if the stream previosly played read until C.TIME_END_OF_SOURCE.

enable already makes all changes done in resetPosition (except resetting
the reading position), so it's less error-prone and makes the intention
clearer if the same code is called from both enable and resetPosition.

The effect of this bug was quite limited because the numerical value
of readingPositionUs was only relevant for periods with changing
durations and server-side inserted ads.

PiperOrigin-RevId: 422300690
  • Loading branch information
tonihei committed Jan 17, 2022
1 parent d0c1373 commit 3f47da1
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ public final void enable(
Assertions.checkState(state == STATE_DISABLED);
this.configuration = configuration;
state = STATE_ENABLED;
lastResetPositionUs = positionUs;
onEnabled(joining, mayRenderStartOfStream);
replaceStream(formats, stream, startPositionUs, offsetUs);
onPositionReset(positionUs, joining);
resetPosition(positionUs, joining);
}

@Override
Expand Down Expand Up @@ -159,10 +158,14 @@ public final void maybeThrowStreamError() throws IOException {

@Override
public final void resetPosition(long positionUs) throws ExoPlaybackException {
resetPosition(positionUs, /* joining= */ false);
}

private void resetPosition(long positionUs, boolean joining) throws ExoPlaybackException {
streamIsFinal = false;
lastResetPositionUs = positionUs;
readingPositionUs = positionUs;
onPositionReset(positionUs, false);
onPositionReset(positionUs, joining);
}

@Override
Expand Down

0 comments on commit 3f47da1

Please sign in to comment.