Fix bug that caused failure when all renderers disabled.
Prior to this change, there was a bug where playback would fail with the following steps: 1. Start playback. 2. Pause playback. 3. Disable all renderers. 4. Enable at least one renderer. 5. Resume playback.
This commit is contained in:
parent
33d55631ed
commit
2b27137e9e
@ -163,6 +163,7 @@ public class ChunkSampleSource implements SampleSource, SampleSourceReader, Load
|
|||||||
downstreamMediaFormat = null;
|
downstreamMediaFormat = null;
|
||||||
downstreamPositionUs = positionUs;
|
downstreamPositionUs = positionUs;
|
||||||
lastSeekPositionUs = positionUs;
|
lastSeekPositionUs = positionUs;
|
||||||
|
pendingDiscontinuity = false;
|
||||||
restartFrom(positionUs);
|
restartFrom(positionUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +171,6 @@ public class ChunkSampleSource implements SampleSource, SampleSourceReader, Load
|
|||||||
public void disable(int track) {
|
public void disable(int track) {
|
||||||
Assertions.checkState(state == STATE_ENABLED);
|
Assertions.checkState(state == STATE_ENABLED);
|
||||||
Assertions.checkState(track == 0);
|
Assertions.checkState(track == 0);
|
||||||
pendingDiscontinuity = false;
|
|
||||||
state = STATE_PREPARED;
|
state = STATE_PREPARED;
|
||||||
try {
|
try {
|
||||||
chunkSource.disable(mediaChunks);
|
chunkSource.disable(mediaChunks);
|
||||||
@ -269,12 +269,14 @@ public class ChunkSampleSource implements SampleSource, SampleSourceReader, Load
|
|||||||
@Override
|
@Override
|
||||||
public void seekToUs(long positionUs) {
|
public void seekToUs(long positionUs) {
|
||||||
Assertions.checkState(state == STATE_ENABLED);
|
Assertions.checkState(state == STATE_ENABLED);
|
||||||
|
|
||||||
|
long currentPositionUs = isPendingReset() ? pendingResetPositionUs : downstreamPositionUs;
|
||||||
|
downstreamPositionUs = positionUs;
|
||||||
lastSeekPositionUs = positionUs;
|
lastSeekPositionUs = positionUs;
|
||||||
if ((isPendingReset() ? pendingResetPositionUs : downstreamPositionUs) == positionUs) {
|
if (currentPositionUs == positionUs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
downstreamPositionUs = positionUs;
|
|
||||||
// If we're not pending a reset, see if we can seek within the sample queue.
|
// If we're not pending a reset, see if we can seek within the sample queue.
|
||||||
boolean seekInsideBuffer = !isPendingReset() && sampleQueue.skipToKeyframeBefore(positionUs);
|
boolean seekInsideBuffer = !isPendingReset() && sampleQueue.skipToKeyframeBefore(positionUs);
|
||||||
if (seekInsideBuffer) {
|
if (seekInsideBuffer) {
|
||||||
|
@ -194,6 +194,7 @@ public class ExtractorSampleSource implements SampleSource, SampleSourceReader,
|
|||||||
if (enabledTrackCount == 1) {
|
if (enabledTrackCount == 1) {
|
||||||
seekToUs(positionUs);
|
seekToUs(positionUs);
|
||||||
}
|
}
|
||||||
|
pendingDiscontinuities[track] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -202,8 +203,8 @@ public class ExtractorSampleSource implements SampleSource, SampleSourceReader,
|
|||||||
Assertions.checkState(trackEnabledStates[track]);
|
Assertions.checkState(trackEnabledStates[track]);
|
||||||
enabledTrackCount--;
|
enabledTrackCount--;
|
||||||
trackEnabledStates[track] = false;
|
trackEnabledStates[track] = false;
|
||||||
pendingDiscontinuities[track] = false;
|
|
||||||
if (enabledTrackCount == 0) {
|
if (enabledTrackCount == 0) {
|
||||||
|
downstreamPositionUs = Long.MIN_VALUE;
|
||||||
if (loader.isLoading()) {
|
if (loader.isLoading()) {
|
||||||
loader.cancelLoading();
|
loader.cancelLoading();
|
||||||
} else {
|
} else {
|
||||||
@ -274,13 +275,13 @@ public class ExtractorSampleSource implements SampleSource, SampleSourceReader,
|
|||||||
positionUs = 0;
|
positionUs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long currentPositionUs = isPendingReset() ? pendingResetPositionUs : downstreamPositionUs;
|
||||||
|
downstreamPositionUs = positionUs;
|
||||||
lastSeekPositionUs = positionUs;
|
lastSeekPositionUs = positionUs;
|
||||||
if ((isPendingReset() ? pendingResetPositionUs : downstreamPositionUs) == positionUs) {
|
if (currentPositionUs == positionUs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
downstreamPositionUs = positionUs;
|
|
||||||
|
|
||||||
// If we're not pending a reset, see if we can seek within the sample queues.
|
// If we're not pending a reset, see if we can seek within the sample queues.
|
||||||
boolean seekInsideBuffer = !isPendingReset();
|
boolean seekInsideBuffer = !isPendingReset();
|
||||||
for (int i = 0; seekInsideBuffer && i < sampleQueues.size(); i++) {
|
for (int i = 0; seekInsideBuffer && i < sampleQueues.size(); i++) {
|
||||||
|
@ -193,6 +193,7 @@ public class HlsSampleSource implements SampleSource, SampleSourceReader, Loader
|
|||||||
if (enabledTrackCount == 1) {
|
if (enabledTrackCount == 1) {
|
||||||
seekToUs(positionUs);
|
seekToUs(positionUs);
|
||||||
}
|
}
|
||||||
|
pendingDiscontinuities[track] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -201,8 +202,8 @@ public class HlsSampleSource implements SampleSource, SampleSourceReader, Loader
|
|||||||
Assertions.checkState(trackEnabledStates[track]);
|
Assertions.checkState(trackEnabledStates[track]);
|
||||||
enabledTrackCount--;
|
enabledTrackCount--;
|
||||||
trackEnabledStates[track] = false;
|
trackEnabledStates[track] = false;
|
||||||
pendingDiscontinuities[track] = false;
|
|
||||||
if (enabledTrackCount == 0) {
|
if (enabledTrackCount == 0) {
|
||||||
|
downstreamPositionUs = Long.MIN_VALUE;
|
||||||
if (loadControlRegistered) {
|
if (loadControlRegistered) {
|
||||||
loadControl.unregister(this);
|
loadControl.unregister(this);
|
||||||
loadControlRegistered = false;
|
loadControlRegistered = false;
|
||||||
@ -314,8 +315,11 @@ public class HlsSampleSource implements SampleSource, SampleSourceReader, Loader
|
|||||||
public void seekToUs(long positionUs) {
|
public void seekToUs(long positionUs) {
|
||||||
Assertions.checkState(prepared);
|
Assertions.checkState(prepared);
|
||||||
Assertions.checkState(enabledTrackCount > 0);
|
Assertions.checkState(enabledTrackCount > 0);
|
||||||
|
|
||||||
|
long currentPositionUs = isPendingReset() ? pendingResetPositionUs : downstreamPositionUs;
|
||||||
|
downstreamPositionUs = positionUs;
|
||||||
lastSeekPositionUs = positionUs;
|
lastSeekPositionUs = positionUs;
|
||||||
if ((isPendingReset() ? pendingResetPositionUs : downstreamPositionUs) == positionUs) {
|
if (currentPositionUs == positionUs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user