Don't retry UnexpectedLoaderExceptions.

These are thrown for non-IOException encountered during loading. Also, they
are thrown from an unexpected position and retrying is likely to fail anyway
because the Extractor is left in an unrecoverable state.

PiperOrigin-RevId: 237043948
This commit is contained in:
tonihei 2019-03-06 15:31:00 +00:00 committed by Oliver Woodman
parent ab5dae64b9
commit ea42bfbf34

View file

@ -18,6 +18,7 @@ package com.google.android.exoplayer2.upstream;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException;
import com.google.android.exoplayer2.upstream.Loader.UnexpectedLoaderException;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -77,14 +78,16 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
}
/**
* Retries for any exception that is not a subclass of {@link ParserException} or {@link
* FileNotFoundException}. The retry delay is calculated as {@code Math.min((errorCount - 1) *
* 1000, 5000)}.
* Retries for any exception that is not a subclass of {@link ParserException}, {@link
* FileNotFoundException} or {@link UnexpectedLoaderException}. The retry delay is calculated as
* {@code Math.min((errorCount - 1) * 1000, 5000)}.
*/
@Override
public long getRetryDelayMsFor(
int dataType, long loadDurationMs, IOException exception, int errorCount) {
return exception instanceof ParserException || exception instanceof FileNotFoundException
return exception instanceof ParserException
|| exception instanceof FileNotFoundException
|| exception instanceof UnexpectedLoaderException
? C.TIME_UNSET
: Math.min((errorCount - 1) * 1000, 5000);
}