mirror of
https://github.com/samsonjs/media.git
synced 2026-06-29 05:39:31 +00:00
Add ERROR_CODE_TIMEOUT.
Also remove the method for creating a TYPE_RENDERER ExoPlaybackException with unknown renderer name and index. PiperOrigin-RevId: 382589655
This commit is contained in:
parent
dda1d37368
commit
ee0d905eed
6 changed files with 37 additions and 41 deletions
|
|
@ -46,6 +46,7 @@ public class PlaybackException extends Exception implements Bundleable {
|
|||
ERROR_CODE_UNSPECIFIED,
|
||||
ERROR_CODE_REMOTE_ERROR,
|
||||
ERROR_CODE_BEHIND_LIVE_WINDOW,
|
||||
ERROR_CODE_TIMEOUT,
|
||||
ERROR_CODE_IO_UNSPECIFIED,
|
||||
ERROR_CODE_IO_NETWORK_UNAVAILABLE,
|
||||
ERROR_CODE_IO_NETWORK_CONNECTION_FAILED,
|
||||
|
|
@ -89,6 +90,8 @@ public class PlaybackException extends Exception implements Bundleable {
|
|||
public static final int ERROR_CODE_REMOTE_ERROR = 1001;
|
||||
/** Caused by the loading position falling behind the sliding window of available live content. */
|
||||
public static final int ERROR_CODE_BEHIND_LIVE_WINDOW = 1002;
|
||||
/** Caused by a generic timeout. */
|
||||
public static final int ERROR_CODE_TIMEOUT = 1003;
|
||||
|
||||
// Input/Output errors (2xxx).
|
||||
|
||||
|
|
@ -199,6 +202,8 @@ public class PlaybackException extends Exception implements Bundleable {
|
|||
return "ERROR_CODE_REMOTE_ERROR";
|
||||
case ERROR_CODE_BEHIND_LIVE_WINDOW:
|
||||
return "ERROR_CODE_BEHIND_LIVE_WINDOW";
|
||||
case ERROR_CODE_TIMEOUT:
|
||||
return "ERROR_CODE_TIMEOUT";
|
||||
case ERROR_CODE_IO_UNSPECIFIED:
|
||||
return "ERROR_CODE_IO_UNSPECIFIED";
|
||||
case ERROR_CODE_IO_NETWORK_UNAVAILABLE:
|
||||
|
|
|
|||
|
|
@ -60,10 +60,12 @@ public class ExoPlaybackExceptionTest {
|
|||
|
||||
@Test
|
||||
public void
|
||||
roundTripViaBundle_ofExoPlaybackExceptionTypeRendererWithPrivateCause_yieldsRemoteExceptionWithSameMessage() {
|
||||
roundTripViaBundle_ofExoPlaybackExceptionTypeUnexpectedWithPrivateCause_yieldsRemoteExceptionWithSameMessage() {
|
||||
ExoPlaybackException before =
|
||||
ExoPlaybackException.createForRenderer(
|
||||
new Exception(/* message= */ "anonymous exception that class loader cannot know") {});
|
||||
ExoPlaybackException.createForUnexpected(
|
||||
new RuntimeException(
|
||||
/* message= */ "anonymous exception that class loader cannot know") {},
|
||||
PlaybackException.ERROR_CODE_TIMEOUT);
|
||||
ExoPlaybackException after = ExoPlaybackException.CREATOR.fromBundle(before.toBundle());
|
||||
|
||||
assertThat(after.getCause()).isInstanceOf(RemoteException.class);
|
||||
|
|
|
|||
|
|
@ -71,16 +71,10 @@ public final class ExoPlaybackException extends PlaybackException {
|
|||
/** The {@link Type} of the playback failure. */
|
||||
@Type public final int type;
|
||||
|
||||
/**
|
||||
* If {@link #type} is {@link #TYPE_RENDERER}, this is the name of the renderer, or null if
|
||||
* unknown.
|
||||
*/
|
||||
/** If {@link #type} is {@link #TYPE_RENDERER}, this is the name of the renderer. */
|
||||
@Nullable public final String rendererName;
|
||||
|
||||
/**
|
||||
* If {@link #type} is {@link #TYPE_RENDERER}, this is the index of the renderer, or {@link
|
||||
* C#INDEX_UNSET} if unknown.
|
||||
*/
|
||||
/** If {@link #type} is {@link #TYPE_RENDERER}, this is the index of the renderer. */
|
||||
public final int rendererIndex;
|
||||
|
||||
/**
|
||||
|
|
@ -128,26 +122,8 @@ public final class ExoPlaybackException extends PlaybackException {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of type {@link #TYPE_RENDERER} for an unknown renderer.
|
||||
*
|
||||
* @param cause The cause of the failure.
|
||||
* @return The created instance.
|
||||
*/
|
||||
public static ExoPlaybackException createForRenderer(Exception cause) {
|
||||
return new ExoPlaybackException(
|
||||
TYPE_RENDERER,
|
||||
cause,
|
||||
/* customMessage= */ null,
|
||||
ERROR_CODE_UNSPECIFIED,
|
||||
/* rendererName */ null,
|
||||
/* rendererIndex= */ C.INDEX_UNSET,
|
||||
/* rendererFormat= */ null,
|
||||
/* rendererFormatSupport= */ C.FORMAT_HANDLED,
|
||||
/* isRecoverable= */ false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of type {@link #TYPE_RENDERER}.
|
||||
* Creates an instance of type {@link #TYPE_RENDERER} in which {@link #isRecoverable} is {@code
|
||||
* false} and {@link #errorCode} is {@link #ERROR_CODE_UNSPECIFIED}.
|
||||
*
|
||||
* @param cause The cause of the failure.
|
||||
* @param rendererIndex The index of the renderer in which the failure occurred.
|
||||
|
|
@ -207,14 +183,25 @@ public final class ExoPlaybackException extends PlaybackException {
|
|||
isRecoverable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #createForUnexpected(RuntimeException, int)
|
||||
* createForUnexpected(RuntimeException, ERROR_CODE_UNSPECIFIED)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ExoPlaybackException createForUnexpected(RuntimeException cause) {
|
||||
return createForUnexpected(cause, ERROR_CODE_UNSPECIFIED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of type {@link #TYPE_UNEXPECTED}.
|
||||
*
|
||||
* @param cause The cause of the failure.
|
||||
* @param errorCode See {@link #errorCode}.
|
||||
* @return The created instance.
|
||||
*/
|
||||
public static ExoPlaybackException createForUnexpected(RuntimeException cause) {
|
||||
return new ExoPlaybackException(TYPE_UNEXPECTED, cause, ERROR_CODE_UNSPECIFIED);
|
||||
public static ExoPlaybackException createForUnexpected(
|
||||
RuntimeException cause, @ErrorCode int errorCode) {
|
||||
return new ExoPlaybackException(TYPE_UNEXPECTED, cause, errorCode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -804,9 +804,9 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
// One of the renderers timed out releasing its resources.
|
||||
stop(
|
||||
/* reset= */ false,
|
||||
ExoPlaybackException.createForRenderer(
|
||||
new ExoTimeoutException(
|
||||
ExoTimeoutException.TIMEOUT_OPERATION_SET_FOREGROUND_MODE)));
|
||||
ExoPlaybackException.createForUnexpected(
|
||||
new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_SET_FOREGROUND_MODE),
|
||||
PlaybackException.ERROR_CODE_TIMEOUT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -873,8 +873,9 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
Player.EVENT_PLAYER_ERROR,
|
||||
listener ->
|
||||
listener.onPlayerError(
|
||||
ExoPlaybackException.createForRenderer(
|
||||
new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_RELEASE))));
|
||||
ExoPlaybackException.createForUnexpected(
|
||||
new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_RELEASE),
|
||||
PlaybackException.ERROR_CODE_TIMEOUT)));
|
||||
}
|
||||
listeners.release();
|
||||
playbackInfoUpdateHandler.removeCallbacksAndMessages(null);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/** A timeout of an operation on the ExoPlayer playback thread. */
|
||||
public final class ExoTimeoutException extends Exception {
|
||||
public final class ExoTimeoutException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* The operation which produced the timeout error. One of {@link #TIMEOUT_OPERATION_RELEASE},
|
||||
|
|
|
|||
|
|
@ -1953,8 +1953,9 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
// One of the renderers timed out releasing its resources.
|
||||
player.stop(
|
||||
/* reset= */ false,
|
||||
ExoPlaybackException.createForRenderer(
|
||||
new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_DETACH_SURFACE)));
|
||||
ExoPlaybackException.createForUnexpected(
|
||||
new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_DETACH_SURFACE),
|
||||
PlaybackException.ERROR_CODE_TIMEOUT));
|
||||
}
|
||||
if (this.videoOutput == ownedSurface) {
|
||||
// We're replacing a surface that we are responsible for releasing.
|
||||
|
|
|
|||
Loading…
Reference in a new issue