Commit a083c29f by olly Committed by Oliver Woodman

Don't discard when a reset is pending

When a reset is pending the sample queues normally contain pre-seek
samples (which will be emptied when a pending load is canceled). The
position passed to discard will be a post-seek position. I don't
think anything bad happened in any of the cases being changed, but
discarding is unnecessary in such cases, and reasoning about such
cases is difficult.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212435556
parent 46af49e2
......@@ -291,6 +291,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override
public void discardBuffer(long positionUs, boolean toKeyframe) {
if (isPendingReset()) {
return;
}
boolean[] trackEnabledStates = getPreparedState().trackEnabledStates;
int trackCount = sampleQueues.length;
for (int i = 0; i < trackCount; i++) {
......
......@@ -188,6 +188,9 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
* the specified position, rather than any sample before or at that position.
*/
public void discardBuffer(long positionUs, boolean toKeyframe) {
if (isPendingReset()) {
return;
}
int oldFirstIndex = primarySampleQueue.getFirstIndex();
primarySampleQueue.discardTo(positionUs, toKeyframe, true);
int newFirstIndex = primarySampleQueue.getFirstIndex();
......
......@@ -367,7 +367,7 @@ import java.util.List;
}
public void discardBuffer(long positionUs, boolean toKeyframe) {
if (!sampleQueuesBuilt) {
if (!sampleQueuesBuilt || isPendingReset()) {
return;
}
int sampleQueueCount = sampleQueues.length;
......
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