Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a05b54ff authored by Ronghua Wu's avatar Ronghua Wu Committed by Android (Google) Code Review
Browse files

Merge "media: add reason to CodecException ctor."

parents 556a4d23 9e9ec943
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -669,10 +669,10 @@ final public class MediaCodec {
     * Thrown when an internal codec error occurs.
     */
    public final static class CodecException extends IllegalStateException {
        CodecException(int errorCode, int actionCode, String detailMessage) {
        CodecException(int errorCode, int actionCode, String detailMessage, int reason) {
            super(detailMessage);
            mErrorCode = errorCode;
            mReason = REASON_HARDWARE;
            mReason = reason;
            mActionCode = actionCode;

            // TODO get this from codec
+19 −2
Original line number Diff line number Diff line
@@ -70,6 +70,11 @@ static struct CodecActionCodes {
    jint codecActionRecoverable;
} gCodecActionCodes;

static struct ExceptionReason {
    jint reasonHardware;
    jint reasonReclaimed;
} gExceptionReason;

struct fields_t {
    jfieldID context;
    jmethodID postEventFromNativeID;
@@ -568,7 +573,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;)V");
    const jmethodID ctor = env->GetMethodID(clazz.get(), "<init>", "(IILjava/lang/String;I)V");
    CHECK(ctor != NULL);

    ScopedLocalRef<jstring> msgObj(
@@ -587,7 +592,9 @@ static jthrowable createCodecException(
        break;
    }

    return (jthrowable)env->NewObject(clazz.get(), ctor, err, actionCode, msgObj.get());
    // TODO: propagate reason from MediaCodec.
    int reason = gExceptionReason.reasonHardware;
    return (jthrowable)env->NewObject(clazz.get(), ctor, err, actionCode, msgObj.get(), reason);
}

void JMediaCodec::handleCallback(const sp<AMessage> &msg) {
@@ -1454,6 +1461,16 @@ static void android_media_MediaCodec_native_init(JNIEnv *env) {
    CHECK(field != NULL);
    gCodecActionCodes.codecActionRecoverable =
        env->GetStaticIntField(clazz.get(), field);

    field = env->GetStaticFieldID(clazz.get(), "REASON_HARDWARE", "I");
    CHECK(field != NULL);
    gExceptionReason.reasonHardware =
        env->GetStaticIntField(clazz.get(), field);

    field = env->GetStaticFieldID(clazz.get(), "REASON_RECLAIMED", "I");
    CHECK(field != NULL);
    gExceptionReason.reasonReclaimed =
        env->GetStaticIntField(clazz.get(), field);
}

static void android_media_MediaCodec_native_setup(