Restrict Decoder generic exception type to extend DecoderException
This is useful for merging the FFmpeg video support pull request, since it allows a Decoder base class implementation to catch DecoderException rather than forcing it to catch Exception (i.e., everything). Note that unfortunately, Java doesn't allow catching of a generic type (i.e., you cannot "catch (E e)") due to type erasure. PiperOrigin-RevId: 311300719
This commit is contained in:
parent
f599155bbf
commit
a5824f7325
@ -24,7 +24,7 @@ import androidx.annotation.Nullable;
|
||||
* @param <O> The type of buffer output from the decoder.
|
||||
* @param <E> The type of exception thrown from the decoder.
|
||||
*/
|
||||
public interface Decoder<I, O, E extends Exception> {
|
||||
public interface Decoder<I, O, E extends DecoderException> {
|
||||
|
||||
/**
|
||||
* Returns the name of the decoder.
|
||||
|
@ -15,20 +15,36 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.decoder;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/** Thrown when a {@link Decoder} error occurs. */
|
||||
public class DecoderException extends Exception {
|
||||
|
||||
/** @param message The detail message for this exception. */
|
||||
/**
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param message The detail message for this exception.
|
||||
*/
|
||||
public DecoderException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The detail message for this exception.
|
||||
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
|
||||
* A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or unknown.
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param cause The cause of this exception, or {@code null}.
|
||||
*/
|
||||
public DecoderException(String message, Throwable cause) {
|
||||
public DecoderException(@Nullable Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param message The detail message for this exception.
|
||||
* @param cause The cause of this exception, or {@code null}.
|
||||
*/
|
||||
public DecoderException(String message, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import java.util.ArrayDeque;
|
||||
*/
|
||||
@SuppressWarnings("UngroupedOverloads")
|
||||
public abstract class SimpleDecoder<
|
||||
I extends DecoderInputBuffer, O extends OutputBuffer, E extends Exception>
|
||||
I extends DecoderInputBuffer, O extends OutputBuffer, E extends DecoderException>
|
||||
implements Decoder<I, O, E> {
|
||||
|
||||
private final Thread decodeThread;
|
||||
|
@ -15,10 +15,11 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.text;
|
||||
|
||||
/**
|
||||
* Thrown when an error occurs decoding subtitle data.
|
||||
*/
|
||||
public class SubtitleDecoderException extends Exception {
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.decoder.DecoderException;
|
||||
|
||||
/** Thrown when an error occurs decoding subtitle data. */
|
||||
public class SubtitleDecoderException extends DecoderException {
|
||||
|
||||
/**
|
||||
* @param message The detail message for this exception.
|
||||
@ -27,17 +28,16 @@ public class SubtitleDecoderException extends Exception {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/** @param cause The cause of this exception. */
|
||||
public SubtitleDecoderException(Exception cause) {
|
||||
/** @param cause The cause of this exception, or {@code null}. */
|
||||
public SubtitleDecoderException(@Nullable Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The detail message for this exception.
|
||||
* @param cause The cause of this exception.
|
||||
* @param cause The cause of this exception, or {@code null}.
|
||||
*/
|
||||
public SubtitleDecoderException(String message, Throwable cause) {
|
||||
public SubtitleDecoderException(String message, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user