mirror of
https://github.com/samsonjs/media.git
synced 2026-04-08 11:45:51 +00:00
Do not retry failed loads whose error is FileNotFoundException
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=214277073
This commit is contained in:
parent
e86d5efb21
commit
083350b7db
3 changed files with 10 additions and 8 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
### dev-v2 (not yet released) ###
|
||||
|
||||
* Do not retry failed loads whose error is `FileNotFoundException`.
|
||||
* Allow setting log level for ExoPlayer logcat output
|
||||
([#4665](https://github.com/google/ExoPlayer/issues/4665)).
|
||||
* Fix an issue where audio and video would desynchronize when playing
|
||||
|
|
|
|||
|
|
@ -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 java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
/** Default implementation of {@link LoadErrorHandlingPolicy}. */
|
||||
|
|
@ -76,13 +77,14 @@ public final class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPo
|
|||
}
|
||||
|
||||
/**
|
||||
* Retries for any exception that is not a subclass of {@link ParserException}. 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} or {@link
|
||||
* FileNotFoundException}. 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
|
||||
return exception instanceof ParserException || exception instanceof FileNotFoundException
|
||||
? C.TIME_UNSET
|
||||
: Math.min((errorCount - 1) * 1000, 5000);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import android.net.Uri;
|
|||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ParserException;
|
||||
import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import org.junit.Test;
|
||||
|
|
@ -57,7 +56,7 @@ public final class DefaultLoadErrorHandlingPolicyTest {
|
|||
|
||||
@Test
|
||||
public void getBlacklistDurationMsFor_dontBlacklistUnexpectedExceptions() {
|
||||
FileNotFoundException exception = new FileNotFoundException();
|
||||
IOException exception = new IOException();
|
||||
assertThat(getDefaultPolicyBlacklistOutputFor(exception)).isEqualTo(C.TIME_UNSET);
|
||||
}
|
||||
|
||||
|
|
@ -69,9 +68,9 @@ public final class DefaultLoadErrorHandlingPolicyTest {
|
|||
|
||||
@Test
|
||||
public void getRetryDelayMsFor_successiveRetryDelays() {
|
||||
assertThat(getDefaultPolicyRetryDelayOutputFor(new FileNotFoundException(), 3)).isEqualTo(2000);
|
||||
assertThat(getDefaultPolicyRetryDelayOutputFor(new FileNotFoundException(), 5)).isEqualTo(4000);
|
||||
assertThat(getDefaultPolicyRetryDelayOutputFor(new FileNotFoundException(), 9)).isEqualTo(5000);
|
||||
assertThat(getDefaultPolicyRetryDelayOutputFor(new IOException(), 3)).isEqualTo(2000);
|
||||
assertThat(getDefaultPolicyRetryDelayOutputFor(new IOException(), 5)).isEqualTo(4000);
|
||||
assertThat(getDefaultPolicyRetryDelayOutputFor(new IOException(), 9)).isEqualTo(5000);
|
||||
}
|
||||
|
||||
private static long getDefaultPolicyBlacklistOutputFor(IOException exception) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue