diff --git a/RELEASENOTES.md b/RELEASENOTES.md index a73b56a7fe..db15ff8653 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -2,6 +2,8 @@ ### dev-v2 (not yet released) ### +* Add new `ExoPlaybackException` types for remote exceptions and out-of-memory + errors. * HLS: * Prevent unnecessary reloads of initialization segments. * Form an adaptive track group out of audio renditions with matching name. diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java index 5ac4e39546..4a8f8709e9 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java @@ -17,6 +17,7 @@ package com.google.android.exoplayer2; import androidx.annotation.IntDef; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.util.Assertions; import java.io.IOException; @@ -31,7 +32,8 @@ public final class ExoPlaybackException extends Exception { /** * The type of source that produced the error. One of {@link #TYPE_SOURCE}, {@link #TYPE_RENDERER} - * {@link #TYPE_UNEXPECTED}, {@link #TYPE_REMOTE} or {@link #TYPE_OUT_OF_MEMORY}. + * {@link #TYPE_UNEXPECTED}, {@link #TYPE_REMOTE} or {@link #TYPE_OUT_OF_MEMORY}. Note that new + * types may be added in the future and error handling should handle unknown type values. */ @Documented @Retention(RetentionPolicy.SOURCE) @@ -64,10 +66,7 @@ public final class ExoPlaybackException extends Exception { /** The error was an {@link OutOfMemoryError}. */ public static final int TYPE_OUT_OF_MEMORY = 4; - /** - * The type of the playback failure. One of {@link #TYPE_SOURCE}, {@link #TYPE_RENDERER}, {@link - * #TYPE_UNEXPECTED}, {@link #TYPE_REMOTE} and {@link #TYPE_OUT_OF_MEMORY}. - */ + /** The {@link Type} of the playback failure. */ @Type public final int type; /** @@ -104,7 +103,8 @@ public final class ExoPlaybackException extends Exception { * @param cause The cause of the failure. * @return The created instance. */ - /* package */ static ExoPlaybackException createForUnexpected(RuntimeException cause) { + @VisibleForTesting + public static ExoPlaybackException createForUnexpected(RuntimeException cause) { return new ExoPlaybackException(TYPE_UNEXPECTED, cause, /* rendererIndex= */ C.INDEX_UNSET); } @@ -124,7 +124,8 @@ public final class ExoPlaybackException extends Exception { * @param cause The cause of the failure. * @return The created instance. */ - /* package */ static ExoPlaybackException createForOutOfMemoryError(OutOfMemoryError cause) { + @VisibleForTesting + public static ExoPlaybackException createForOutOfMemoryError(OutOfMemoryError cause) { return new ExoPlaybackException(TYPE_OUT_OF_MEMORY, cause, /* rendererIndex= */ C.INDEX_UNSET); }