[libbluray-devel] Move bdj_get_method() to bdj.c

hpi1 git at videolan.org
Tue Oct 28 12:09:44 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Oct 28 12:01:08 2014 +0200| [85da5b77b827695103949a93076169b5c7bd4b9f] | committer: hpi1

Move bdj_get_method() to bdj.c

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=85da5b77b827695103949a93076169b5c7bd4b9f
---

 src/libbluray/bdj/bdj.c      |   40 +++++++++++++++++++++++++++++++++-------
 src/libbluray/bdj/bdj_util.c |   27 ---------------------------
 src/libbluray/bdj/bdj_util.h |    4 ----
 3 files changed, 33 insertions(+), 38 deletions(-)

diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index f8824b4..8dbaeef 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -25,16 +25,16 @@
 #include "bdj.h"
 
 #include "bdj_private.h"
-#include "bdjo_parser.h"
-#include "bdj_util.h"
-#include "libbluray/register.h"
+#include "native/register_native.h"
+
 #include "file/dirs.h"
 #include "file/dl.h"
 #include "util/strutl.h"
 #include "util/macro.h"
 #include "util/logging.h"
+
+#include "libbluray/register.h"
 #include "libbluray/bdnav/bdid_parse.h"
-#include "libbluray/bdj/native/register_native.h"
 
 #include <jni.h>
 #include <stdio.h>
@@ -316,6 +316,32 @@ static const char *_bdj_buda_root(BDJ_STORAGE *storage)
     return root;
 }
 
+static int _get_method(JNIEnv *env, jclass *cls, jmethodID *method_id,
+                       const char *class_name, const char *method_name, const char *method_sig)
+{
+    *method_id = NULL;
+    *cls = (*env)->FindClass(env, class_name);
+    if (!*cls) {
+        (*env)->ExceptionDescribe(env);
+        BD_DEBUG(DBG_BDJ | DBG_CRIT, "Failed to locate class %s\n", class_name);
+        (*env)->ExceptionClear(env);
+        return 0;
+    }
+
+    *method_id = (*env)->GetStaticMethodID(env, *cls, method_name, method_sig);
+    if (!*method_id) {
+        (*env)->ExceptionDescribe(env);
+        BD_DEBUG(DBG_BDJ | DBG_CRIT, "Failed to locate class %s method %s %s\n",
+                 class_name, method_name, method_sig);
+        (*env)->DeleteLocalRef(env, *cls);
+        *cls = NULL;
+        (*env)->ExceptionClear(env);
+        return 0;
+    }
+
+    return 1;
+}
+
 static int _bdj_init(BDJAVA *bdjava, JNIEnv *env)
 {
     if (!bdj_register_native_methods(env)) {
@@ -325,7 +351,7 @@ static int _bdj_init(BDJAVA *bdjava, JNIEnv *env)
     // initialize class org.videolan.Libbluray
     jclass init_class;
     jmethodID init_id;
-    if (!bdj_get_method(env, &init_class, &init_id,
+    if (!_get_method(env, &init_class, &init_id,
                         "org/videolan/Libbluray", "init", "(JLjava/lang/String;Ljava/lang/String;)V")) {
         return 0;
     }
@@ -529,7 +555,7 @@ void bdj_close(BDJAVA *bdjava)
             attach = 1;
         }
 
-        if (bdj_get_method(env, &shutdown_class, &shutdown_id,
+        if (_get_method(env, &shutdown_class, &shutdown_id,
                            "org/videolan/Libbluray", "shutdown", "()V")) {
             (*env)->CallStaticVoidMethod(env, shutdown_class, shutdown_id);
 
@@ -595,7 +621,7 @@ int bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param)
         attach = 1;
     }
 
-    if (bdj_get_method(env, &event_class, &event_id,
+    if (_get_method(env, &event_class, &event_id,
                        "org/videolan/Libbluray", "processEvent", "(II)Z")) {
         if ((*env)->CallStaticBooleanMethod(env, event_class, event_id, ev, param)) {
             result = 0;
diff --git a/src/libbluray/bdj/bdj_util.c b/src/libbluray/bdj/bdj_util.c
index ef8efa3..71eac26 100644
--- a/src/libbluray/bdj/bdj_util.c
+++ b/src/libbluray/bdj/bdj_util.c
@@ -45,30 +45,3 @@ jobjectArray bdj_make_array(JNIEnv* env, const char* name, int count)
     jclass arr_class = (*env)->FindClass(env, name);
     return (*env)->NewObjectArray(env, count, arr_class, NULL);
 }
-
-int bdj_get_method(JNIEnv *env, jclass *cls, jmethodID *method_id,
-                   const char *class_name, const char *method_name, const char *method_sig)
-{
-    *method_id = NULL;
-    *cls = (*env)->FindClass(env, class_name);
-    if (!*cls) {
-        (*env)->ExceptionDescribe(env);
-        BD_DEBUG(DBG_BDJ | DBG_CRIT, "Failed to locate class %s\n", class_name);
-        (*env)->ExceptionClear(env);
-        return 0;
-    }
-
-    *method_id = (*env)->GetStaticMethodID(env, *cls, method_name, method_sig);
-    if (!*method_id) {
-        (*env)->ExceptionDescribe(env);
-        BD_DEBUG(DBG_BDJ | DBG_CRIT, "Failed to locate class %s method %s %s\n",
-                 class_name, method_name, method_sig);
-        (*env)->DeleteLocalRef(env, *cls);
-        *cls = NULL;
-        (*env)->ExceptionClear(env);
-        return 0;
-    }
-
-    return 1;
-}
-
diff --git a/src/libbluray/bdj/bdj_util.h b/src/libbluray/bdj/bdj_util.h
index e60acbf..01219a3 100644
--- a/src/libbluray/bdj/bdj_util.h
+++ b/src/libbluray/bdj/bdj_util.h
@@ -31,8 +31,4 @@ BD_PRIVATE jobject bdj_make_object(JNIEnv* env, const char* name, const char* si
 // makes an array for the specified class name, all elements are initialized to null
 BD_PRIVATE jobjectArray bdj_make_array(JNIEnv* env, const char* name, int count);
 
-// get java method
-BD_PRIVATE int bdj_get_method(JNIEnv *env, jclass *cls, jmethodID *method_id,
-                              const char *class_name, const char *method_name, const char *method_sig);
-
 #endif



More information about the libbluray-devel mailing list