From ea42bfbf3452c64454676cfedef446865002c3b5 Mon Sep 17 00:00:00 2001 From: tonihei Date: Wed, 6 Mar 2019 15:31:00 +0000 Subject: [PATCH] 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 --- .../upstream/DefaultLoadErrorHandlingPolicy.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicy.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicy.java index 720a8b08d4..307652f456 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicy.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicy.java @@ -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); }