Commit 3cb58626 by olly Committed by Oliver Woodman

Only pass "throwing" part of Loader to MediaSource children

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128492613
parent 47346c39
...@@ -18,7 +18,7 @@ package com.google.android.exoplayer2.source.dash; ...@@ -18,7 +18,7 @@ package com.google.android.exoplayer2.source.dash;
import com.google.android.exoplayer2.source.chunk.ChunkSource; import com.google.android.exoplayer2.source.chunk.ChunkSource;
import com.google.android.exoplayer2.source.dash.manifest.DashManifest; import com.google.android.exoplayer2.source.dash.manifest.DashManifest;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.Loader; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
/** /**
* An {@link ChunkSource} for DASH streams. * An {@link ChunkSource} for DASH streams.
...@@ -27,9 +27,9 @@ public interface DashChunkSource extends ChunkSource { ...@@ -27,9 +27,9 @@ public interface DashChunkSource extends ChunkSource {
interface Factory { interface Factory {
DashChunkSource createDashChunkSource(Loader manifestLoader, DashManifest manifest, DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
int periodIndex, int adaptationSetIndex, TrackSelection trackSelection, DashManifest manifest, int periodIndex, int adaptationSetIndex,
long elapsedRealtimeOffsetMs); TrackSelection trackSelection, long elapsedRealtimeOffsetMs);
} }
......
...@@ -31,7 +31,7 @@ import com.google.android.exoplayer2.source.dash.manifest.Period; ...@@ -31,7 +31,7 @@ import com.google.android.exoplayer2.source.dash.manifest.Period;
import com.google.android.exoplayer2.source.dash.manifest.Representation; import com.google.android.exoplayer2.source.dash.manifest.Representation;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.Loader; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
...@@ -46,7 +46,7 @@ import java.util.List; ...@@ -46,7 +46,7 @@ import java.util.List;
private final int minLoadableRetryCount; private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final long elapsedRealtimeOffset; private final long elapsedRealtimeOffset;
private final Loader loader; private final LoaderErrorThrower manifestLoaderErrorThrower;
private final TrackGroupArray trackGroups; private final TrackGroupArray trackGroups;
private ChunkSampleStream<DashChunkSource>[] sampleStreams; private ChunkSampleStream<DashChunkSource>[] sampleStreams;
...@@ -60,14 +60,15 @@ import java.util.List; ...@@ -60,14 +60,15 @@ import java.util.List;
public DashMediaPeriod(DashManifest manifest, int index, public DashMediaPeriod(DashManifest manifest, int index,
DashChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, DashChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
EventDispatcher eventDispatcher, long elapsedRealtimeOffset, Loader loader) { EventDispatcher eventDispatcher, long elapsedRealtimeOffset,
LoaderErrorThrower manifestLoaderErrorThrower) {
this.manifest = manifest; this.manifest = manifest;
this.index = index; this.index = index;
this.chunkSourceFactory = chunkSourceFactory; this.chunkSourceFactory = chunkSourceFactory;
this.minLoadableRetryCount = minLoadableRetryCount; this.minLoadableRetryCount = minLoadableRetryCount;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.elapsedRealtimeOffset = elapsedRealtimeOffset; this.elapsedRealtimeOffset = elapsedRealtimeOffset;
this.loader = loader; this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
durationUs = manifest.dynamic ? C.UNSET_TIME_US : manifest.getPeriodDuration(index) * 1000; durationUs = manifest.dynamic ? C.UNSET_TIME_US : manifest.getPeriodDuration(index) * 1000;
period = manifest.getPeriod(index); period = manifest.getPeriod(index);
trackGroups = buildTrackGroups(period); trackGroups = buildTrackGroups(period);
...@@ -99,7 +100,7 @@ import java.util.List; ...@@ -99,7 +100,7 @@ import java.util.List;
@Override @Override
public void maybeThrowPrepareError() throws IOException { public void maybeThrowPrepareError() throws IOException {
loader.maybeThrowError(); manifestLoaderErrorThrower.maybeThrowError();
} }
@Override @Override
...@@ -219,8 +220,9 @@ import java.util.List; ...@@ -219,8 +220,9 @@ import java.util.List;
long positionUs) { long positionUs) {
int adaptationSetIndex = trackGroups.indexOf(selection.group); int adaptationSetIndex = trackGroups.indexOf(selection.group);
AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex); AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex);
DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource(loader, manifest, index, DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource(
adaptationSetIndex, selection, elapsedRealtimeOffset); manifestLoaderErrorThrower, manifest, index, adaptationSetIndex, selection,
elapsedRealtimeOffset);
return new ChunkSampleStream<>(adaptationSet.type, chunkSource, this, allocator, positionUs, return new ChunkSampleStream<>(adaptationSet.type, chunkSource, this, allocator, positionUs,
minLoadableRetryCount, eventDispatcher); minLoadableRetryCount, eventDispatcher);
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.source.dash; package com.google.android.exoplayer2.source.dash;
import android.os.SystemClock;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.ChunkIndex; import com.google.android.exoplayer2.extractor.ChunkIndex;
...@@ -41,9 +40,12 @@ import com.google.android.exoplayer2.trackselection.TrackSelection; ...@@ -41,9 +40,12 @@ import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException; import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException;
import com.google.android.exoplayer2.upstream.Loader; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import android.os.SystemClock;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
...@@ -64,19 +66,20 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -64,19 +66,20 @@ public class DefaultDashChunkSource implements DashChunkSource {
} }
@Override @Override
public DashChunkSource createDashChunkSource(Loader manifestLoader, DashManifest manifest, public DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
int periodIndex, int adaptationSetIndex, TrackSelection trackSelection, DashManifest manifest, int periodIndex, int adaptationSetIndex,
long elapsedRealtimeOffsetMs) { TrackSelection trackSelection, long elapsedRealtimeOffsetMs) {
FormatEvaluator adaptiveEvaluator = trackSelection.length > 1 FormatEvaluator adaptiveEvaluator = trackSelection.length > 1
? formatEvaluatorFactory.createFormatEvaluator() : null; ? formatEvaluatorFactory.createFormatEvaluator() : null;
DataSource dataSource = dataSourceFactory.createDataSource(); DataSource dataSource = dataSourceFactory.createDataSource();
return new DefaultDashChunkSource(manifestLoader, manifest, periodIndex, adaptationSetIndex, return new DefaultDashChunkSource(manifestLoaderErrorThrower, manifest, periodIndex,
trackSelection, dataSource, adaptiveEvaluator, elapsedRealtimeOffsetMs); adaptationSetIndex, trackSelection, dataSource, adaptiveEvaluator,
elapsedRealtimeOffsetMs);
} }
} }
private final Loader manifestLoader; private final LoaderErrorThrower manifestLoaderErrorThrower;
private final int adaptationSetIndex; private final int adaptationSetIndex;
private final TrackSelection trackSelection; private final TrackSelection trackSelection;
private final RepresentationHolder[] representationHolders; private final RepresentationHolder[] representationHolders;
...@@ -93,7 +96,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -93,7 +96,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
private boolean missingLastSegment; private boolean missingLastSegment;
/** /**
* @param manifestLoader The {@link Loader} being used to load manifests. * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
* @param manifest The initial manifest. * @param manifest The initial manifest.
* @param periodIndex The index of the period in the manifest. * @param periodIndex The index of the period in the manifest.
* @param adaptationSetIndex The index of the adaptation set in the period. * @param adaptationSetIndex The index of the adaptation set in the period.
...@@ -104,10 +107,11 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -104,10 +107,11 @@ public class DefaultDashChunkSource implements DashChunkSource {
* server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified * server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
* as the server's unix time minus the local elapsed time. If unknown, set to 0. * as the server's unix time minus the local elapsed time. If unknown, set to 0.
*/ */
public DefaultDashChunkSource(Loader manifestLoader, DashManifest manifest, int periodIndex, public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
int adaptationSetIndex, TrackSelection trackSelection, DataSource dataSource, DashManifest manifest, int periodIndex, int adaptationSetIndex, TrackSelection trackSelection,
FormatEvaluator adaptiveFormatEvaluator, long elapsedRealtimeOffsetMs) { DataSource dataSource, FormatEvaluator adaptiveFormatEvaluator,
this.manifestLoader = manifestLoader; long elapsedRealtimeOffsetMs) {
this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
this.manifest = manifest; this.manifest = manifest;
this.adaptationSetIndex = adaptationSetIndex; this.adaptationSetIndex = adaptationSetIndex;
this.trackSelection = trackSelection; this.trackSelection = trackSelection;
...@@ -151,7 +155,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -151,7 +155,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
if (fatalError != null) { if (fatalError != null) {
throw fatalError; throw fatalError;
} else { } else {
manifestLoader.maybeThrowError(); manifestLoaderErrorThrower.maybeThrowError();
} }
} }
......
...@@ -33,7 +33,7 @@ import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest. ...@@ -33,7 +33,7 @@ import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.Loader; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import android.net.Uri; import android.net.Uri;
...@@ -57,19 +57,19 @@ public class DefaultSsChunkSource implements SsChunkSource { ...@@ -57,19 +57,19 @@ public class DefaultSsChunkSource implements SsChunkSource {
} }
@Override @Override
public SsChunkSource createChunkSource(Loader manifestLoader, SsManifest manifest, public SsChunkSource createChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
int elementIndex, TrackSelection trackSelection, SsManifest manifest, int elementIndex, TrackSelection trackSelection,
TrackEncryptionBox[] trackEncryptionBoxes) { TrackEncryptionBox[] trackEncryptionBoxes) {
FormatEvaluator adaptiveEvaluator = trackSelection.length > 1 FormatEvaluator adaptiveEvaluator = trackSelection.length > 1
? formatEvaluatorFactory.createFormatEvaluator() : null; ? formatEvaluatorFactory.createFormatEvaluator() : null;
DataSource dataSource = dataSourceFactory.createDataSource(); DataSource dataSource = dataSourceFactory.createDataSource();
return new DefaultSsChunkSource(manifestLoader, manifest, elementIndex, trackSelection, return new DefaultSsChunkSource(manifestLoaderErrorThrower, manifest, elementIndex,
dataSource, adaptiveEvaluator, trackEncryptionBoxes); trackSelection, dataSource, adaptiveEvaluator, trackEncryptionBoxes);
} }
} }
private final Loader manifestLoader; private final LoaderErrorThrower manifestLoaderErrorThrower;
private final int elementIndex; private final int elementIndex;
private final TrackSelection trackSelection; private final TrackSelection trackSelection;
private final ChunkExtractorWrapper[] extractorWrappers; private final ChunkExtractorWrapper[] extractorWrappers;
...@@ -84,7 +84,7 @@ public class DefaultSsChunkSource implements SsChunkSource { ...@@ -84,7 +84,7 @@ public class DefaultSsChunkSource implements SsChunkSource {
private IOException fatalError; private IOException fatalError;
/** /**
* @param manifestLoader The {@link Loader} being used to load manifests. * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
* @param manifest The initial manifest. * @param manifest The initial manifest.
* @param elementIndex The index of the stream element in the manifest. * @param elementIndex The index of the stream element in the manifest.
* @param trackSelection The track selection. * @param trackSelection The track selection.
...@@ -92,10 +92,10 @@ public class DefaultSsChunkSource implements SsChunkSource { ...@@ -92,10 +92,10 @@ public class DefaultSsChunkSource implements SsChunkSource {
* @param adaptiveFormatEvaluator For adaptive tracks, selects from the available formats. * @param adaptiveFormatEvaluator For adaptive tracks, selects from the available formats.
* @param trackEncryptionBoxes Track encryption boxes for the stream. * @param trackEncryptionBoxes Track encryption boxes for the stream.
*/ */
public DefaultSsChunkSource(Loader manifestLoader, SsManifest manifest, int elementIndex, public DefaultSsChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, SsManifest manifest,
TrackSelection trackSelection, DataSource dataSource, FormatEvaluator adaptiveFormatEvaluator, int elementIndex, TrackSelection trackSelection, DataSource dataSource,
TrackEncryptionBox[] trackEncryptionBoxes) { FormatEvaluator adaptiveFormatEvaluator, TrackEncryptionBox[] trackEncryptionBoxes) {
this.manifestLoader = manifestLoader; this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
this.manifest = manifest; this.manifest = manifest;
this.elementIndex = elementIndex; this.elementIndex = elementIndex;
this.trackSelection = trackSelection; this.trackSelection = trackSelection;
...@@ -156,7 +156,7 @@ public class DefaultSsChunkSource implements SsChunkSource { ...@@ -156,7 +156,7 @@ public class DefaultSsChunkSource implements SsChunkSource {
if (fatalError != null) { if (fatalError != null) {
throw fatalError; throw fatalError;
} else { } else {
manifestLoader.maybeThrowError(); manifestLoaderErrorThrower.maybeThrowError();
} }
} }
......
...@@ -19,7 +19,7 @@ import com.google.android.exoplayer2.extractor.mp4.TrackEncryptionBox; ...@@ -19,7 +19,7 @@ import com.google.android.exoplayer2.extractor.mp4.TrackEncryptionBox;
import com.google.android.exoplayer2.source.chunk.ChunkSource; import com.google.android.exoplayer2.source.chunk.ChunkSource;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest; import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.Loader; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
/** /**
* A {@link ChunkSource} for SmoothStreaming. * A {@link ChunkSource} for SmoothStreaming.
...@@ -28,8 +28,9 @@ public interface SsChunkSource extends ChunkSource { ...@@ -28,8 +28,9 @@ public interface SsChunkSource extends ChunkSource {
interface Factory { interface Factory {
SsChunkSource createChunkSource(Loader manifestLoader, SsManifest manifest, int elementIndex, SsChunkSource createChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
TrackSelection trackSelection, TrackEncryptionBox[] trackEncryptionBoxes); SsManifest manifest, int elementIndex, TrackSelection trackSelection,
TrackEncryptionBox[] trackEncryptionBoxes);
} }
......
...@@ -29,7 +29,7 @@ import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest; ...@@ -29,7 +29,7 @@ import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.ProtectionElement; import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.ProtectionElement;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.Loader; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import android.util.Base64; import android.util.Base64;
...@@ -45,7 +45,7 @@ import java.util.List; ...@@ -45,7 +45,7 @@ import java.util.List;
private static final int INITIALIZATION_VECTOR_SIZE = 8; private static final int INITIALIZATION_VECTOR_SIZE = 8;
private final SsChunkSource.Factory chunkSourceFactory; private final SsChunkSource.Factory chunkSourceFactory;
private final Loader manifestLoader; private final LoaderErrorThrower manifestLoaderErrorThrower;
private final int minLoadableRetryCount; private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final TrackGroupArray trackGroups; private final TrackGroupArray trackGroups;
...@@ -58,10 +58,11 @@ import java.util.List; ...@@ -58,10 +58,11 @@ import java.util.List;
private Allocator allocator; private Allocator allocator;
public SsMediaPeriod(SsManifest manifest, SsChunkSource.Factory chunkSourceFactory, public SsMediaPeriod(SsManifest manifest, SsChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount, EventDispatcher eventDispatcher, Loader manifestLoader) { int minLoadableRetryCount, EventDispatcher eventDispatcher,
LoaderErrorThrower manifestLoaderErrorThrower) {
this.manifest = manifest; this.manifest = manifest;
this.chunkSourceFactory = chunkSourceFactory; this.chunkSourceFactory = chunkSourceFactory;
this.manifestLoader = manifestLoader; this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
this.minLoadableRetryCount = minLoadableRetryCount; this.minLoadableRetryCount = minLoadableRetryCount;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
trackGroups = buildTrackGroups(manifest); trackGroups = buildTrackGroups(manifest);
...@@ -96,7 +97,7 @@ import java.util.List; ...@@ -96,7 +97,7 @@ import java.util.List;
@Override @Override
public void maybeThrowPrepareError() throws IOException { public void maybeThrowPrepareError() throws IOException {
manifestLoader.maybeThrowError(); manifestLoaderErrorThrower.maybeThrowError();
} }
@Override @Override
...@@ -199,8 +200,8 @@ import java.util.List; ...@@ -199,8 +200,8 @@ import java.util.List;
private ChunkSampleStream<SsChunkSource> buildSampleStream(TrackSelection selection, private ChunkSampleStream<SsChunkSource> buildSampleStream(TrackSelection selection,
long positionUs) { long positionUs) {
int streamElementIndex = trackGroups.indexOf(selection.group); int streamElementIndex = trackGroups.indexOf(selection.group);
SsChunkSource chunkSource = chunkSourceFactory.createChunkSource(manifestLoader, manifest, SsChunkSource chunkSource = chunkSourceFactory.createChunkSource(manifestLoaderErrorThrower,
streamElementIndex, selection, trackEncryptionBoxes); manifest, streamElementIndex, selection, trackEncryptionBoxes);
return new ChunkSampleStream<>(manifest.streamElements[streamElementIndex].type, chunkSource, return new ChunkSampleStream<>(manifest.streamElements[streamElementIndex].type, chunkSource,
this, allocator, positionUs, minLoadableRetryCount, eventDispatcher); this, allocator, positionUs, minLoadableRetryCount, eventDispatcher);
} }
......
...@@ -32,7 +32,7 @@ import java.util.concurrent.ExecutorService; ...@@ -32,7 +32,7 @@ import java.util.concurrent.ExecutorService;
/** /**
* Manages the background loading of {@link Loadable}s. * Manages the background loading of {@link Loadable}s.
*/ */
public final class Loader { public final class Loader implements LoaderErrorThrower {
/** /**
* Thrown when an unexpected exception is encountered during loading. * Thrown when an unexpected exception is encountered during loading.
...@@ -174,34 +174,6 @@ public final class Loader { ...@@ -174,34 +174,6 @@ public final class Loader {
} }
/** /**
* Throws an error if a fatal error has been encountered, or if the current {@link Loadable} has
* incurred a number of errors greater than its default minimum number of retries and if the load
* is currently backed off, then an error is thrown. Else does nothing.
*
* @throws IOException The error.
*/
public void maybeThrowError() throws IOException {
maybeThrowError(Integer.MIN_VALUE);
}
/**
* Throws an error if a fatal error has been encountered, or if the current {@link Loadable} has
* incurred a number of errors greater than the specified minimum number of retries and if the
* load is currently backed off, then an error is thrown.
*
* @param minRetryCount A minimum retry count that must be exceeded.
* @throws IOException The error.
*/
public void maybeThrowError(int minRetryCount) throws IOException {
if (fatalError != null) {
throw fatalError;
} else if (currentTask != null) {
currentTask.maybeThrowError(minRetryCount == Integer.MIN_VALUE
? currentTask.defaultMinRetryCount : minRetryCount);
}
}
/**
* Cancels the current load. This method should only be called when a load is in progress. * Cancels the current load. This method should only be called when a load is in progress.
*/ */
public void cancelLoading() { public void cancelLoading() {
...@@ -233,6 +205,25 @@ public final class Loader { ...@@ -233,6 +205,25 @@ public final class Loader {
downloadExecutorService.shutdown(); downloadExecutorService.shutdown();
} }
// LoaderErrorThrower implementation.
@Override
public void maybeThrowError() throws IOException {
maybeThrowError(Integer.MIN_VALUE);
}
@Override
public void maybeThrowError(int minRetryCount) throws IOException {
if (fatalError != null) {
throw fatalError;
} else if (currentTask != null) {
currentTask.maybeThrowError(minRetryCount == Integer.MIN_VALUE
? currentTask.defaultMinRetryCount : minRetryCount);
}
}
// Internal classes.
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
private final class LoadTask<T extends Loadable> extends Handler implements Runnable { private final class LoadTask<T extends Loadable> extends Handler implements Runnable {
......
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.upstream;
import com.google.android.exoplayer2.upstream.Loader.Loadable;
import java.io.IOException;
/**
* Conditionally throws errors affecting a {@link Loader}.
*/
public interface LoaderErrorThrower {
/**
* Throws a fatal error, or a non-fatal error if loading is currently backed off and the current
* {@link Loadable} has incurred a number of errors greater than the {@link Loader}s default
* minimum number of retries. Else does nothing.
*
* @throws IOException The error.
*/
void maybeThrowError() throws IOException;
/**
* Throws a fatal error, or a non-fatal error if loading is currently backed off and the current
* {@link Loadable} has incurred a number of errors greater than the specified minimum number
* of retries. Else does nothing.
*
* @param minRetryCount A minimum retry count that must be exceeded for a non-fatal error to be
* thrown. Should be non-negative.
* @throws IOException The error.
*/
void maybeThrowError(int minRetryCount) throws IOException;
}
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