[Android] [WIP PATCH 07/11] utils: add throw_exception
Thomas Guillem
thomas at gllm.fr
Tue Dec 23 18:38:28 CET 2014
---
libvlc/jni/libvlcjni.c | 7 +++----
libvlc/jni/utils.h | 7 +++++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index 3678175..8737e42 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -359,10 +359,9 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
(*env)->ReleaseStringUTFChars(env, chroma, chromastr);
(*env)->ReleaseStringUTFChars(env, subsencoding, subsencodingstr);
- if (!instance)
- {
- jclass exc = (*env)->FindClass(env, "org/videolan/libvlc/LibVlcException");
- (*env)->ThrowNew(env, exc, "Unable to instantiate LibVLC");
+ if (!instance) {
+ throw_exception(env, "Unable to instantiate LibVLC");
+ return;
}
LOGI("LibVLC initialized: %p", instance);
diff --git a/libvlc/jni/utils.h b/libvlc/jni/utils.h
index 5da3514..b6df0cf 100644
--- a/libvlc/jni/utils.h
+++ b/libvlc/jni/utils.h
@@ -21,6 +21,13 @@
#ifndef LIBVLCJNI_UTILS_H
#define LIBVLCJNI_UTILS_H
+static inline void throw_exception(JNIEnv *env, const char *p_error)
+{
+ jclass exc = (*env)->FindClass(env, "org/videolan/libvlc/LibVlcException");
+ (*env)->ThrowNew(env, exc, p_error);
+}
+
+
libvlc_media_t *new_media(JNIEnv *env, jobject thiz, jstring fileLocation, bool noOmx, bool noVideo);
libvlc_instance_t *getLibVlcInstance(JNIEnv *env, jobject thiz);
--
2.1.3
More information about the Android
mailing list