Commit 377e550d by tonihei Committed by Oliver Woodman

Improve new error type documentation and prevent NPE in error listener.

Adding new error types may cause issues when listeners assume a fixed set of
error types and don't handle arbitrary defaults.

Fixing error handling in one case and improving documentation to make people
aware of the issue.

PiperOrigin-RevId: 236093265
parent 92a7bb53
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
### dev-v2 (not yet released) ### ### dev-v2 (not yet released) ###
* Add new `ExoPlaybackException` types for remote exceptions and out-of-memory
errors.
* HLS: * HLS:
* Prevent unnecessary reloads of initialization segments. * Prevent unnecessary reloads of initialization segments.
* Form an adaptive track group out of audio renditions with matching name. * Form an adaptive track group out of audio renditions with matching name.
......
...@@ -17,6 +17,7 @@ package com.google.android.exoplayer2; ...@@ -17,6 +17,7 @@ package com.google.android.exoplayer2;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException; import java.io.IOException;
...@@ -31,7 +32,8 @@ public final class ExoPlaybackException extends Exception { ...@@ -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} * 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 @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
...@@ -64,10 +66,7 @@ public final class ExoPlaybackException extends Exception { ...@@ -64,10 +66,7 @@ public final class ExoPlaybackException extends Exception {
/** The error was an {@link OutOfMemoryError}. */ /** The error was an {@link OutOfMemoryError}. */
public static final int TYPE_OUT_OF_MEMORY = 4; public static final int TYPE_OUT_OF_MEMORY = 4;
/** /** The {@link Type} of the playback failure. */
* 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}.
*/
@Type public final int type; @Type public final int type;
/** /**
...@@ -104,7 +103,8 @@ public final class ExoPlaybackException extends Exception { ...@@ -104,7 +103,8 @@ public final class ExoPlaybackException extends Exception {
* @param cause The cause of the failure. * @param cause The cause of the failure.
* @return The created instance. * @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); return new ExoPlaybackException(TYPE_UNEXPECTED, cause, /* rendererIndex= */ C.INDEX_UNSET);
} }
...@@ -124,7 +124,8 @@ public final class ExoPlaybackException extends Exception { ...@@ -124,7 +124,8 @@ public final class ExoPlaybackException extends Exception {
* @param cause The cause of the failure. * @param cause The cause of the failure.
* @return The created instance. * @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); return new ExoPlaybackException(TYPE_OUT_OF_MEMORY, cause, /* rendererIndex= */ C.INDEX_UNSET);
} }
......
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