diff options
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | media/java/android/media/MediaCodec.java | 8 | ||||
-rw-r--r-- | media/jni/android_media_MediaCodec.cpp | 21 |
3 files changed, 18 insertions, 13 deletions
diff --git a/api/current.txt b/api/current.txt index b6e4993..f09291d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -14336,7 +14336,7 @@ package android.media { public static abstract class MediaCodec.Callback { ctor public MediaCodec.Callback(); - method public abstract void onError(android.media.MediaCodec, int, int); + method public abstract void onError(android.media.MediaCodec, android.media.MediaCodec.CodecException); method public abstract void onInputBufferAvailable(android.media.MediaCodec, int); method public abstract void onOutputBufferAvailable(android.media.MediaCodec, int, android.media.MediaCodec.BufferInfo); method public abstract void onOutputFormatChanged(android.media.MediaCodec, android.media.MediaFormat); diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 4a94cde..cb9776a 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -332,8 +332,7 @@ final public class MediaCodec { case CB_ERROR: { - mCallback.onError(mCodec, - msg.arg2 /* error */, (Integer) msg.obj /* actionCode */); + mCallback.onError(mCodec, (MediaCodec.CodecException) msg.obj); break; } @@ -1454,10 +1453,9 @@ final public class MediaCodec { * Called when the MediaCodec encountered an error * * @param codec The MediaCodec object. - * @param error a device specific error code. - * @param actionCode a value for use in {@link MediaCodec.CodecException}. + * @param e The {@link MediaCodec.CodecException} object describing the error. */ - public abstract void onError(MediaCodec codec, int error, int actionCode); + public abstract void onError(MediaCodec codec, CodecException e); /** * Called when the output format has changed diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp index efdacfb..6a835d6 100644 --- a/media/jni/android_media_MediaCodec.cpp +++ b/media/jni/android_media_MediaCodec.cpp @@ -566,20 +566,27 @@ void JMediaCodec::handleCallback(const sp<AMessage> &msg) { case MediaCodec::CB_ERROR: { - CHECK(msg->findInt32("err", &arg2)); - - int32_t actionCode; + int32_t err, actionCode; + CHECK(msg->findInt32("err", &err)); CHECK(msg->findInt32("actionCode", &actionCode)); // use Integer object to pass the action code ScopedLocalRef<jclass> clazz( - env, env->FindClass("java/lang/Integer")); - jmethodID ctor = env->GetMethodID(clazz.get(), "<init>", "(I)V"); - obj = env->NewObject(clazz.get(), ctor, actionCode); + env, env->FindClass("android/media/MediaCodec$CodecException")); + jmethodID ctor = env->GetMethodID(clazz.get(), "<init>", "(IILjava/lang/String;)V"); + + AString str; + const char *detail = "Unknown error"; + if (msg->findString("detail", &str)) { + detail = str.c_str(); + } + jstring msgObj = env->NewStringUTF(detail); + + obj = env->NewObject(clazz.get(), ctor, err, actionCode, msgObj); if (obj == NULL) { if (env->ExceptionCheck()) { - ALOGE("Could not create Integer object for actionCode."); + ALOGE("Could not create CodecException object."); env->ExceptionClear(); } jniThrowException(env, "java/lang/IllegalStateException", NULL); |