Loading api/current.txt +3 −3 Original line number Diff line number Diff line Loading @@ -15415,11 +15415,11 @@ package android.media { public static final class MediaCodec.CodecException extends java.lang.IllegalStateException { method public java.lang.String getDiagnosticInfo(); method public int getReason(); method public int getErrorCode(); method public boolean isRecoverable(); method public boolean isTransient(); field public static final int REASON_HARDWARE = 0; // 0x0 field public static final int REASON_RECLAIMED = 1; // 0x1 field public static final int ERROR_INSUFFICIENT_RESOURCE = 1100; // 0x44c field public static final int ERROR_RECLAIMED = 1101; // 0x44d } public static final class MediaCodec.CryptoException extends java.lang.RuntimeException { api/system-current.txt +3 −3 Original line number Diff line number Diff line Loading @@ -16637,11 +16637,11 @@ package android.media { public static final class MediaCodec.CodecException extends java.lang.IllegalStateException { method public java.lang.String getDiagnosticInfo(); method public int getReason(); method public int getErrorCode(); method public boolean isRecoverable(); method public boolean isTransient(); field public static final int REASON_HARDWARE = 0; // 0x0 field public static final int REASON_RECLAIMED = 1; // 0x1 field public static final int ERROR_INSUFFICIENT_RESOURCE = 1100; // 0x44c field public static final int ERROR_RECLAIMED = 1101; // 0x44d } public static final class MediaCodec.CryptoException extends java.lang.RuntimeException { media/java/android/media/MediaCodec.java +8 −25 Original line number Diff line number Diff line Loading @@ -816,10 +816,9 @@ final public class MediaCodec { * Thrown when an internal codec error occurs. */ public final static class CodecException extends IllegalStateException { CodecException(int errorCode, int actionCode, @Nullable String detailMessage, int reason) { CodecException(int errorCode, int actionCode, @Nullable String detailMessage) { super(detailMessage); mErrorCode = errorCode; mReason = reason; mActionCode = actionCode; // TODO get this from codec Loading Loading @@ -847,21 +846,7 @@ final public class MediaCodec { } /** * Retrieve the reason associated with a CodecException. * The reason could be one of {@link #REASON_HARDWARE} or {@link #REASON_RECLAIMED}. * */ @ReasonCode public int getReason() { return mReason; } /** * Retrieve the error code associated with a CodecException. * This is opaque diagnostic information and may depend on * hardware or API level. * * @hide * Retrieve the error code associated with a CodecException */ public int getErrorCode() { return mErrorCode; Loading @@ -878,22 +863,21 @@ final public class MediaCodec { } /** * This indicates the exception is caused by the hardware. * This indicates required resource was not able to be allocated. */ public static final int REASON_HARDWARE = 0; public static final int ERROR_INSUFFICIENT_RESOURCE = 1100; /** * This indicates the exception is because the resource manager reclaimed * the media resource used by the codec. * This indicates the resource manager reclaimed the media resource used by the codec. * <p> * With this exception, the codec must be released, as it has moved to terminal state. */ public static final int REASON_RECLAIMED = 1; public static final int ERROR_RECLAIMED = 1101; /** @hide */ @IntDef({ REASON_HARDWARE, REASON_RECLAIMED, ERROR_INSUFFICIENT_RESOURCE, ERROR_RECLAIMED, }) @Retention(RetentionPolicy.SOURCE) public @interface ReasonCode {} Loading @@ -904,7 +888,6 @@ final public class MediaCodec { private final String mDiagnosticInfo; private final int mErrorCode; private final int mReason; private final int mActionCode; } Loading media/jni/android_media_MediaCodec.cpp +27 −12 Original line number Diff line number Diff line Loading @@ -70,10 +70,10 @@ static struct CodecActionCodes { jint codecActionRecoverable; } gCodecActionCodes; static struct ExceptionReason { jint reasonHardware; jint reasonReclaimed; } gExceptionReason; static struct CodecErrorCodes { jint errorInsufficientResource; jint errorReclaimed; } gCodecErrorCodes; static struct { jclass clazz; Loading Loading @@ -600,7 +600,7 @@ static jthrowable createCodecException( env, env->FindClass("android/media/MediaCodec$CodecException")); CHECK(clazz.get() != NULL); const jmethodID ctor = env->GetMethodID(clazz.get(), "<init>", "(IILjava/lang/String;I)V"); const jmethodID ctor = env->GetMethodID(clazz.get(), "<init>", "(IILjava/lang/String;)V"); CHECK(ctor != NULL); ScopedLocalRef<jstring> msgObj( Loading @@ -619,9 +619,19 @@ static jthrowable createCodecException( break; } int reason = (err == DEAD_OBJECT) ? gExceptionReason.reasonReclaimed : gExceptionReason.reasonHardware; return (jthrowable)env->NewObject(clazz.get(), ctor, err, actionCode, msgObj.get(), reason); /* translate OS errors to Java API CodecException errorCodes */ switch (err) { case NO_MEMORY: err = gCodecErrorCodes.errorInsufficientResource; break; case DEAD_OBJECT: err = gCodecErrorCodes.errorReclaimed; break; default: /* Other error codes go out as is. */ break; } return (jthrowable)env->NewObject(clazz.get(), ctor, err, actionCode, msgObj.get()); } void JMediaCodec::handleCallback(const sp<AMessage> &msg) { Loading Loading @@ -1636,14 +1646,14 @@ static void android_media_MediaCodec_native_init(JNIEnv *env) { gCodecActionCodes.codecActionRecoverable = env->GetStaticIntField(clazz.get(), field); field = env->GetStaticFieldID(clazz.get(), "REASON_HARDWARE", "I"); field = env->GetStaticFieldID(clazz.get(), "ERROR_INSUFFICIENT_RESOURCE", "I"); CHECK(field != NULL); gExceptionReason.reasonHardware = gCodecErrorCodes.errorInsufficientResource = env->GetStaticIntField(clazz.get(), field); field = env->GetStaticFieldID(clazz.get(), "REASON_RECLAIMED", "I"); field = env->GetStaticFieldID(clazz.get(), "ERROR_RECLAIMED", "I"); CHECK(field != NULL); gExceptionReason.reasonReclaimed = gCodecErrorCodes.errorReclaimed = env->GetStaticIntField(clazz.get(), field); clazz.reset(env->FindClass("android/view/Surface")); Loading Loading @@ -1693,6 +1703,11 @@ static void android_media_MediaCodec_native_setup( String8::format("Failed to initialize %s, error %#x", tmp, err)); env->ReleaseStringUTFChars(name, tmp); return; } if (err == NO_MEMORY) { throwCodecException(env, err, ACTION_CODE_TRANSIENT, String8::format("Failed to initialize %s, error %#x", tmp, err)); env->ReleaseStringUTFChars(name, tmp); return; } else if (err != OK) { // believed possible to try again jniThrowException(env, "java/io/IOException", Loading Loading
api/current.txt +3 −3 Original line number Diff line number Diff line Loading @@ -15415,11 +15415,11 @@ package android.media { public static final class MediaCodec.CodecException extends java.lang.IllegalStateException { method public java.lang.String getDiagnosticInfo(); method public int getReason(); method public int getErrorCode(); method public boolean isRecoverable(); method public boolean isTransient(); field public static final int REASON_HARDWARE = 0; // 0x0 field public static final int REASON_RECLAIMED = 1; // 0x1 field public static final int ERROR_INSUFFICIENT_RESOURCE = 1100; // 0x44c field public static final int ERROR_RECLAIMED = 1101; // 0x44d } public static final class MediaCodec.CryptoException extends java.lang.RuntimeException {
api/system-current.txt +3 −3 Original line number Diff line number Diff line Loading @@ -16637,11 +16637,11 @@ package android.media { public static final class MediaCodec.CodecException extends java.lang.IllegalStateException { method public java.lang.String getDiagnosticInfo(); method public int getReason(); method public int getErrorCode(); method public boolean isRecoverable(); method public boolean isTransient(); field public static final int REASON_HARDWARE = 0; // 0x0 field public static final int REASON_RECLAIMED = 1; // 0x1 field public static final int ERROR_INSUFFICIENT_RESOURCE = 1100; // 0x44c field public static final int ERROR_RECLAIMED = 1101; // 0x44d } public static final class MediaCodec.CryptoException extends java.lang.RuntimeException {
media/java/android/media/MediaCodec.java +8 −25 Original line number Diff line number Diff line Loading @@ -816,10 +816,9 @@ final public class MediaCodec { * Thrown when an internal codec error occurs. */ public final static class CodecException extends IllegalStateException { CodecException(int errorCode, int actionCode, @Nullable String detailMessage, int reason) { CodecException(int errorCode, int actionCode, @Nullable String detailMessage) { super(detailMessage); mErrorCode = errorCode; mReason = reason; mActionCode = actionCode; // TODO get this from codec Loading Loading @@ -847,21 +846,7 @@ final public class MediaCodec { } /** * Retrieve the reason associated with a CodecException. * The reason could be one of {@link #REASON_HARDWARE} or {@link #REASON_RECLAIMED}. * */ @ReasonCode public int getReason() { return mReason; } /** * Retrieve the error code associated with a CodecException. * This is opaque diagnostic information and may depend on * hardware or API level. * * @hide * Retrieve the error code associated with a CodecException */ public int getErrorCode() { return mErrorCode; Loading @@ -878,22 +863,21 @@ final public class MediaCodec { } /** * This indicates the exception is caused by the hardware. * This indicates required resource was not able to be allocated. */ public static final int REASON_HARDWARE = 0; public static final int ERROR_INSUFFICIENT_RESOURCE = 1100; /** * This indicates the exception is because the resource manager reclaimed * the media resource used by the codec. * This indicates the resource manager reclaimed the media resource used by the codec. * <p> * With this exception, the codec must be released, as it has moved to terminal state. */ public static final int REASON_RECLAIMED = 1; public static final int ERROR_RECLAIMED = 1101; /** @hide */ @IntDef({ REASON_HARDWARE, REASON_RECLAIMED, ERROR_INSUFFICIENT_RESOURCE, ERROR_RECLAIMED, }) @Retention(RetentionPolicy.SOURCE) public @interface ReasonCode {} Loading @@ -904,7 +888,6 @@ final public class MediaCodec { private final String mDiagnosticInfo; private final int mErrorCode; private final int mReason; private final int mActionCode; } Loading
media/jni/android_media_MediaCodec.cpp +27 −12 Original line number Diff line number Diff line Loading @@ -70,10 +70,10 @@ static struct CodecActionCodes { jint codecActionRecoverable; } gCodecActionCodes; static struct ExceptionReason { jint reasonHardware; jint reasonReclaimed; } gExceptionReason; static struct CodecErrorCodes { jint errorInsufficientResource; jint errorReclaimed; } gCodecErrorCodes; static struct { jclass clazz; Loading Loading @@ -600,7 +600,7 @@ static jthrowable createCodecException( env, env->FindClass("android/media/MediaCodec$CodecException")); CHECK(clazz.get() != NULL); const jmethodID ctor = env->GetMethodID(clazz.get(), "<init>", "(IILjava/lang/String;I)V"); const jmethodID ctor = env->GetMethodID(clazz.get(), "<init>", "(IILjava/lang/String;)V"); CHECK(ctor != NULL); ScopedLocalRef<jstring> msgObj( Loading @@ -619,9 +619,19 @@ static jthrowable createCodecException( break; } int reason = (err == DEAD_OBJECT) ? gExceptionReason.reasonReclaimed : gExceptionReason.reasonHardware; return (jthrowable)env->NewObject(clazz.get(), ctor, err, actionCode, msgObj.get(), reason); /* translate OS errors to Java API CodecException errorCodes */ switch (err) { case NO_MEMORY: err = gCodecErrorCodes.errorInsufficientResource; break; case DEAD_OBJECT: err = gCodecErrorCodes.errorReclaimed; break; default: /* Other error codes go out as is. */ break; } return (jthrowable)env->NewObject(clazz.get(), ctor, err, actionCode, msgObj.get()); } void JMediaCodec::handleCallback(const sp<AMessage> &msg) { Loading Loading @@ -1636,14 +1646,14 @@ static void android_media_MediaCodec_native_init(JNIEnv *env) { gCodecActionCodes.codecActionRecoverable = env->GetStaticIntField(clazz.get(), field); field = env->GetStaticFieldID(clazz.get(), "REASON_HARDWARE", "I"); field = env->GetStaticFieldID(clazz.get(), "ERROR_INSUFFICIENT_RESOURCE", "I"); CHECK(field != NULL); gExceptionReason.reasonHardware = gCodecErrorCodes.errorInsufficientResource = env->GetStaticIntField(clazz.get(), field); field = env->GetStaticFieldID(clazz.get(), "REASON_RECLAIMED", "I"); field = env->GetStaticFieldID(clazz.get(), "ERROR_RECLAIMED", "I"); CHECK(field != NULL); gExceptionReason.reasonReclaimed = gCodecErrorCodes.errorReclaimed = env->GetStaticIntField(clazz.get(), field); clazz.reset(env->FindClass("android/view/Surface")); Loading Loading @@ -1693,6 +1703,11 @@ static void android_media_MediaCodec_native_setup( String8::format("Failed to initialize %s, error %#x", tmp, err)); env->ReleaseStringUTFChars(name, tmp); return; } if (err == NO_MEMORY) { throwCodecException(env, err, ACTION_CODE_TRANSIENT, String8::format("Failed to initialize %s, error %#x", tmp, err)); env->ReleaseStringUTFChars(name, tmp); return; } else if (err != OK) { // believed possible to try again jniThrowException(env, "java/io/IOException", Loading