@Test public void testContinueLoadingReturnAllowAllLoadersBehindPlaybackPositionToLoad() { FakeSequenceableLoader loader1 = new FakeSequenceableLoader( 1000, 2000); FakeSequenceableLoader loader2 = new FakeSequenceableLoader( 1001, 2001); FakeSequenceableLoader loader3 = new FakeSequenceableLoader( 1002, 2002); CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( new SequenceableLoader[] {loader1, loader2, loader3}); compositeSequenceableLoader.continueLoading(3000); assertThat(loader1.numInvocations).isEqualTo(1); assertThat(loader2.numInvocations).isEqualTo(1); assertThat(loader3.numInvocations).isEqualTo(1); }
@Override public boolean continueLoading(long positionUs) { boolean madeProgress = false; boolean madeProgressThisIteration; do { madeProgressThisIteration = false; long nextLoadPositionUs = getNextLoadPositionUs(); if (nextLoadPositionUs == C.TIME_END_OF_SOURCE) { break; } for (SequenceableLoader loader : loaders) { long loaderNextLoadPositionUs = loader.getNextLoadPositionUs(); boolean isLoaderBehind = loaderNextLoadPositionUs != C.TIME_END_OF_SOURCE && loaderNextLoadPositionUs <= positionUs; if (loaderNextLoadPositionUs == nextLoadPositionUs || isLoaderBehind) { madeProgressThisIteration |= loader.continueLoading(positionUs); } } madeProgress |= madeProgressThisIteration; } while (madeProgressThisIteration); return madeProgress; }
CompositeSequenceableLoader implements SequenceableLoader { @Override public boolean continueLoading(long positionUs) { boolean madeProgress = false; boolean madeProgressThisIteration; do { madeProgressThisIteration = false; long nextLoadPositionUs = getNextLoadPositionUs(); if (nextLoadPositionUs == C.TIME_END_OF_SOURCE) { break; } for (SequenceableLoader loader : loaders) { long loaderNextLoadPositionUs = loader.getNextLoadPositionUs(); boolean isLoaderBehind = loaderNextLoadPositionUs != C.TIME_END_OF_SOURCE && loaderNextLoadPositionUs <= positionUs; if (loaderNextLoadPositionUs == nextLoadPositionUs || isLoaderBehind) { madeProgressThisIteration |= loader.continueLoading(positionUs); } } madeProgress |= madeProgressThisIteration; } while (madeProgressThisIteration); return madeProgress; } }
CompositeSequenceableLoader implements SequenceableLoader { @Override public boolean continueLoading(long positionUs) { boolean madeProgress = false; boolean madeProgressThisIteration; do { madeProgressThisIteration = false; long nextLoadPositionUs = getNextLoadPositionUs(); if (nextLoadPositionUs == C.TIME_END_OF_SOURCE) { break; } for (SequenceableLoader loader : loaders) { long loaderNextLoadPositionUs = loader.getNextLoadPositionUs(); boolean isLoaderBehind = loaderNextLoadPositionUs != C.TIME_END_OF_SOURCE && loaderNextLoadPositionUs <= positionUs; if (loaderNextLoadPositionUs == nextLoadPositionUs || isLoaderBehind) { madeProgressThisIteration |= loader.continueLoading(positionUs); } } madeProgress |= madeProgressThisIteration; } while (madeProgressThisIteration); return madeProgress; } CompositeSequenceableLoader(SequenceableLoader[] loaders); }
CompositeSequenceableLoader implements SequenceableLoader { @Override public boolean continueLoading(long positionUs) { boolean madeProgress = false; boolean madeProgressThisIteration; do { madeProgressThisIteration = false; long nextLoadPositionUs = getNextLoadPositionUs(); if (nextLoadPositionUs == C.TIME_END_OF_SOURCE) { break; } for (SequenceableLoader loader : loaders) { long loaderNextLoadPositionUs = loader.getNextLoadPositionUs(); boolean isLoaderBehind = loaderNextLoadPositionUs != C.TIME_END_OF_SOURCE && loaderNextLoadPositionUs <= positionUs; if (loaderNextLoadPositionUs == nextLoadPositionUs || isLoaderBehind) { madeProgressThisIteration |= loader.continueLoading(positionUs); } } madeProgress |= madeProgressThisIteration; } while (madeProgressThisIteration); return madeProgress; } CompositeSequenceableLoader(SequenceableLoader[] loaders); @Override final long getBufferedPositionUs(); @Override final long getNextLoadPositionUs(); @Override final void reevaluateBuffer(long positionUs); @Override boolean continueLoading(long positionUs); }
CompositeSequenceableLoader implements SequenceableLoader { @Override public boolean continueLoading(long positionUs) { boolean madeProgress = false; boolean madeProgressThisIteration; do { madeProgressThisIteration = false; long nextLoadPositionUs = getNextLoadPositionUs(); if (nextLoadPositionUs == C.TIME_END_OF_SOURCE) { break; } for (SequenceableLoader loader : loaders) { long loaderNextLoadPositionUs = loader.getNextLoadPositionUs(); boolean isLoaderBehind = loaderNextLoadPositionUs != C.TIME_END_OF_SOURCE && loaderNextLoadPositionUs <= positionUs; if (loaderNextLoadPositionUs == nextLoadPositionUs || isLoaderBehind) { madeProgressThisIteration |= loader.continueLoading(positionUs); } } madeProgress |= madeProgressThisIteration; } while (madeProgressThisIteration); return madeProgress; } CompositeSequenceableLoader(SequenceableLoader[] loaders); @Override final long getBufferedPositionUs(); @Override final long getNextLoadPositionUs(); @Override final void reevaluateBuffer(long positionUs); @Override boolean continueLoading(long positionUs);  }