[vlc-commits] mediacodec: avoid IllegalStateException on some weird devices

Edward Wang git at videolan.org
Wed Jan 23 20:06:18 CET 2013


vlc | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Jan 17 18:43:05 2013 -0500| [514843b280d0fec6a5bebb6c3476bf415866adf4] | committer: Jean-Baptiste Kempf

mediacodec: avoid IllegalStateException on some weird devices

01-17 18:53:34.959 E/VLC/VlcCrashHandler(16725): java.lang.IllegalStateException
01-17 18:53:34.959 E/VLC/VlcCrashHandler(16725): 	at android.media.MediaCodec.releaseOutputBuffer(Native Method)
01-17 18:53:34.959 E/VLC/VlcCrashHandler(16725): 	at dalvik.system.NativeStart.run(Native Method)

Personally I don't notice any performance regression.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=514843b280d0fec6a5bebb6c3476bf415866adf4
---

 modules/codec/omxil/android_mediacodec.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index ee43cd8..246e7d1 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -419,6 +419,15 @@ static void GetOutput(decoder_t *p_dec, JNIEnv *env, picture_t **pp_pic, int loo
                                ptr, chroma_div);
             }
             (*env)->CallVoidMethod(env, p_sys->codec, p_sys->release_output_buffer, index, false);
+            jthrowable exception = (*env)->ExceptionOccurred(env);
+            if(exception != NULL) {
+                jclass illegalStateException = (*env)->FindClass(env, "java/lang/IllegalStateException");
+                if((*env)->IsInstanceOf(env, exception, illegalStateException)) {
+                    msg_Err(p_dec, "Codec error (IllegalStateException) in MediaCodec.releaseOutputBuffer");
+                    (*env)->ExceptionClear(env);
+                    (*env)->DeleteLocalRef(env, illegalStateException);
+                }
+            }
             (*env)->DeleteLocalRef(env, buf);
         } else if (index == INFO_OUTPUT_BUFFERS_CHANGED) {
             msg_Dbg(p_dec, "output buffers changed");



More information about the vlc-commits mailing list