Commit 2214a4c1 by WeiChungChang

'refine_to_make_flow_simpler'

parent cb0394b9
......@@ -248,12 +248,7 @@ public final class DefaultTrackOutput implements TrackOutput {
* @return Whether the skip was successful.
*/
public boolean skipToKeyframeBefore(long timeUs) {
long nextOffset = infoQueue.skipToKeyframeBefore(timeUs, false);
if (nextOffset == C.POSITION_UNSET) {
return false;
}
dropDownstreamTo(nextOffset);
return true;
return infoQueue.skipToKeyframeBefore(timeUs, false);
}
/**
......
......@@ -115,20 +115,6 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
}
/**
* Check if the input position locates within the chunk we are downloading now.
*
* @param positionUs The target position in microseconds.
* @return Whether the input position locates within the chunk we are downloading now.
*/
public boolean isWithinLastChunk(long positionUs) {
if (isPendingReset() || loadingFinished) {
return false;
} else {
return ((positionUs >= getCurrentLoadPositionUs()) && (positionUs < getNextLoadPositionUs()));
}
}
/**
* Seeks to the specified position in microseconds.
*
* @param positionUs The seek position in microseconds.
......@@ -137,7 +123,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
lastSeekPositionUs = positionUs;
// If we're not pending a reset, see if we can seek within the sample queue.
boolean seekInsideBuffer = !isPendingReset() &&
sampleQueue.skipToKeyframeBefore(positionUs, isWithinLastChunk(positionUs));
sampleQueue.skipToKeyframeBefore(positionUs, (positionUs < getNextLoadPositionUs()));
if (seekInsideBuffer) {
// We succeeded. All we need to do is discard any chunks that we've moved past.
while (mediaChunks.size() > 1
......@@ -299,14 +285,6 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
return true;
}
public long getCurrentLoadPositionUs() {
if (isPendingReset()) {
return pendingResetPositionUs;
} else {
return loadingFinished ? C.TIME_END_OF_SOURCE : mediaChunks.getLast().startTimeUs;
}
}
@Override
public long getNextLoadPositionUs() {
if (isPendingReset()) {
......
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