Commit 97aaee6d by Oliver Woodman

Fix crash introduced by previous change.

parent b8df8ecb
...@@ -353,18 +353,17 @@ public class HlsSampleSource implements SampleSource, SampleSourceReader, Loader ...@@ -353,18 +353,17 @@ public class HlsSampleSource implements SampleSource, SampleSourceReader, Loader
@Override @Override
public void onLoadCompleted(Loadable loadable) { public void onLoadCompleted(Loadable loadable) {
Assertions.checkState(loadable == currentLoadable);
long now = SystemClock.elapsedRealtime(); long now = SystemClock.elapsedRealtime();
long loadDurationMs = now - currentLoadStartTimeMs; long loadDurationMs = now - currentLoadStartTimeMs;
if (currentTsLoadable != null) {
previousTsLoadable = currentTsLoadable;
currentTsLoadable = null;
}
chunkSource.onChunkLoadCompleted(currentLoadable); chunkSource.onChunkLoadCompleted(currentLoadable);
if (isTsChunk(currentLoadable)) { if (isTsChunk(currentLoadable)) {
TsChunk tsChunk = (TsChunk) loadable; Assertions.checkState(currentLoadable == currentTsLoadable);
loadingFinished = tsChunk.isLastChunk; loadingFinished = currentTsLoadable.isLastChunk;
notifyLoadCompleted(currentLoadable.bytesLoaded(), tsChunk.type, tsChunk.trigger, previousTsLoadable = currentTsLoadable;
tsChunk.format, tsChunk.startTimeUs, tsChunk.endTimeUs, now, loadDurationMs); notifyLoadCompleted(currentLoadable.bytesLoaded(), currentTsLoadable.type,
currentTsLoadable.trigger, currentTsLoadable.format, currentTsLoadable.startTimeUs,
currentTsLoadable.endTimeUs, now, loadDurationMs);
} else { } else {
notifyLoadCompleted(currentLoadable.bytesLoaded(), currentLoadable.type, notifyLoadCompleted(currentLoadable.bytesLoaded(), currentLoadable.type,
currentLoadable.trigger, currentLoadable.format, -1, -1, now, loadDurationMs); currentLoadable.trigger, currentLoadable.format, -1, -1, now, loadDurationMs);
...@@ -534,10 +533,10 @@ public class HlsSampleSource implements SampleSource, SampleSourceReader, Loader ...@@ -534,10 +533,10 @@ public class HlsSampleSource implements SampleSource, SampleSourceReader, Loader
private long getNextLoadPositionUs() { private long getNextLoadPositionUs() {
if (isPendingReset()) { if (isPendingReset()) {
return pendingResetPositionUs; return pendingResetPositionUs;
} else if (loader.isLoading()) {
return currentTsLoadable.isLastChunk ? -1 : currentTsLoadable.endTimeUs;
} else { } else {
return previousTsLoadable.isLastChunk ? -1 : previousTsLoadable.endTimeUs; return currentTsLoadable != null
? (currentTsLoadable.isLastChunk ? -1 : currentTsLoadable.endTimeUs)
: (previousTsLoadable.isLastChunk ? -1 : previousTsLoadable.endTimeUs);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment