Commit 61adcf98 by olly Committed by Oliver Woodman

Fix issue seeking backward when using SingleSampleSource.

Issue: #1193
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=117136800
parent c98f7e83
...@@ -58,6 +58,7 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load ...@@ -58,6 +58,7 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load
private byte[] sampleData; private byte[] sampleData;
private int sampleSize; private int sampleSize;
private long pendingResetPositionUs;
private boolean loadingFinished; private boolean loadingFinished;
private Loader loader; private Loader loader;
private IOException currentLoadableException; private IOException currentLoadableException;
...@@ -112,6 +113,7 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load ...@@ -112,6 +113,7 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load
@Override @Override
public TrackStream enable(TrackSelection selection, long positionUs) { public TrackStream enable(TrackSelection selection, long positionUs) {
state = STATE_SEND_FORMAT; state = STATE_SEND_FORMAT;
pendingResetPositionUs = NO_RESET;
clearCurrentLoadableException(); clearCurrentLoadableException();
maybeStartLoading(); maybeStartLoading();
return this; return this;
...@@ -129,7 +131,9 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load ...@@ -129,7 +131,9 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load
@Override @Override
public long readReset() { public long readReset() {
return TrackStream.NO_RESET; long resetPositionUs = pendingResetPositionUs;
pendingResetPositionUs = NO_RESET;
return resetPositionUs;
} }
@Override @Override
...@@ -159,6 +163,7 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load ...@@ -159,6 +163,7 @@ public final class SingleSampleSource implements SampleSource, TrackStream, Load
@Override @Override
public void seekToUs(long positionUs) { public void seekToUs(long positionUs) {
if (state == STATE_END_OF_STREAM) { if (state == STATE_END_OF_STREAM) {
pendingResetPositionUs = positionUs;
state = STATE_SEND_SAMPLE; state = STATE_SEND_SAMPLE;
} }
} }
......
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