Fix issue seeking backward when using SingleSampleSource.

Issue: #1193
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=117136800
This commit is contained in:
olly 2016-03-14 08:49:12 -07:00 committed by Oliver Woodman
parent c98f7e8348
commit 61adcf98d2

View File

@ -58,6 +58,7 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load
private byte[] sampleData;
private int sampleSize;
private long pendingResetPositionUs;
private boolean loadingFinished;
private Loader loader;
private IOException currentLoadableException;
@ -112,6 +113,7 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load
@Override
public TrackStream enable(TrackSelection selection, long positionUs) {
state = STATE_SEND_FORMAT;
pendingResetPositionUs = NO_RESET;
clearCurrentLoadableException();
maybeStartLoading();
return this;
@ -129,7 +131,9 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load
@Override
public long readReset() {
return TrackStream.NO_RESET;
long resetPositionUs = pendingResetPositionUs;
pendingResetPositionUs = NO_RESET;
return resetPositionUs;
}
@Override
@ -159,6 +163,7 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load
@Override
public void seekToUs(long positionUs) {
if (state == STATE_END_OF_STREAM) {
pendingResetPositionUs = positionUs;
state = STATE_SEND_SAMPLE;
}
}