[libbluray-devel] Factorize 70+ lines from Java invocation interface.
hpi1
git at videolan.org
Tue Jan 14 12:35:45 CET 2014
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sat Dec 21 17:28:33 2013 +0200| [7066fa8e7f7a9563bd3db3f9e1ab46a38209d2ca] | committer: hpi1
Factorize 70+ lines from Java invocation interface.
Simplifies moving BD-J to separate process.
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=7066fa8e7f7a9563bd3db3f9e1ab46a38209d2ca
---
src/libbluray/bdj/bdj.c | 79 +-------------------
src/libbluray/bdj/bdj.h | 5 +-
src/libbluray/bdj/java/org/videolan/Libbluray.java | 9 +++
src/libbluray/bluray.c | 4 +-
4 files changed, 17 insertions(+), 80 deletions(-)
diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index c2c88cd..a186895 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -456,82 +456,6 @@ BDJAVA* bdj_open(const char *path, struct bluray *bd,
return bdjava;
}
-int bdj_start(BDJAVA *bdjava, unsigned title)
-{
- JNIEnv* env;
- int attach = 0;
- jboolean status = JNI_FALSE;
- jclass loader_class;
- jmethodID load_id;
-
- if (!bdjava) {
- return BDJ_ERROR;
- }
-
- BD_DEBUG(DBG_BDJ, "bdj_start(%d)\n", title);
-
- if ((*bdjava->jvm)->GetEnv(bdjava->jvm, (void**)&env, JNI_VERSION_1_4) != JNI_OK) {
- (*bdjava->jvm)->AttachCurrentThread(bdjava->jvm, (void**)&env, NULL);
- attach = 1;
- }
-
- if (bdj_get_method(env, &loader_class, &load_id,
- "org/videolan/BDJLoader", "load", "(I)Z")) {
- status = (*env)->CallStaticBooleanMethod(env, loader_class, load_id, (jint)title);
-
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
-
- (*env)->DeleteLocalRef(env, loader_class);
- }
-
- if (attach) {
- (*bdjava->jvm)->DetachCurrentThread(bdjava->jvm);
- }
-
- return (status == JNI_TRUE) ? BDJ_SUCCESS : BDJ_ERROR;
-}
-
-int bdj_stop(BDJAVA *bdjava)
-{
- JNIEnv *env;
- int attach = 0;
- jboolean status = JNI_FALSE;
- jclass loader_class;
- jmethodID unload_id;
-
- if (!bdjava) {
- return BDJ_ERROR;
- }
-
- BD_DEBUG(DBG_BDJ, "bdj_stop()\n");
-
- if ((*bdjava->jvm)->GetEnv(bdjava->jvm, (void**)&env, JNI_VERSION_1_4) != JNI_OK) {
- (*bdjava->jvm)->AttachCurrentThread(bdjava->jvm, (void**)&env, NULL);
- attach = 1;
- }
-
- if (bdj_get_method(env, &loader_class, &unload_id,
- "org/videolan/BDJLoader", "unload", "()Z")) {
- status = (*env)->CallStaticBooleanMethod(env, loader_class, unload_id);
-
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
-
- (*env)->DeleteLocalRef(env, loader_class);
- }
-
- if (attach) {
- (*bdjava->jvm)->DetachCurrentThread(bdjava->jvm);
- }
-
- return (status == JNI_TRUE) ? BDJ_SUCCESS : BDJ_ERROR;
-}
-
void bdj_close(BDJAVA *bdjava)
{
JNIEnv *env;
@@ -592,6 +516,9 @@ int bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param)
"MARK",
"PSR102",
"PLAYLIST",
+
+ "START",
+ "STOP",
};
JNIEnv* env;
diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h
index f7086ff..e921b55 100644
--- a/src/libbluray/bdj/bdj.h
+++ b/src/libbluray/bdj/bdj.h
@@ -37,6 +37,9 @@ typedef enum {
BDJ_EVENT_MARK,
BDJ_EVENT_PSR102,
BDJ_EVENT_PLAYLIST,
+
+ BDJ_EVENT_START, /* param: title number */
+ BDJ_EVENT_STOP,
} BDJ_EVENT;
/* bdj_get_uo_mask() */
@@ -55,8 +58,6 @@ typedef void (*bdj_overlay_cb)(struct bluray *, const unsigned *, int, int,
BD_PRIVATE BDJAVA* bdj_open(const char *path, struct bluray *bd,
struct indx_root_s *index,
bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf);
-BD_PRIVATE int bdj_start(BDJAVA *bdjava, unsigned title);
-BD_PRIVATE int bdj_stop(BDJAVA *bdjava);
BD_PRIVATE void bdj_close(BDJAVA *bdjava);
BD_PRIVATE int bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param);
BD_PRIVATE int bdj_get_uo_mask(BDJAVA *bdjava);
diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index 7bb928f..4cd7d25 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -311,6 +311,12 @@ public class Libbluray {
int key = 0;
switch (event) {
+
+ case BDJ_EVENT_START:
+ return BDJLoader.load(param);
+ case BDJ_EVENT_STOP:
+ return BDJLoader.unload();
+
case BDJ_EVENT_CHAPTER:
BDHandler.onChapterReach(param);
break;
@@ -397,6 +403,9 @@ public class Libbluray {
private static final int BDJ_EVENT_PSR102 = 10;
private static final int BDJ_EVENT_PLAYLIST = 11;
+ private static final int BDJ_EVENT_START = 12;
+ private static final int BDJ_EVENT_STOP = 13;
+
/* TODO: use org/bluray/system/RegisterAccess instead */
public static final int PSR_IG_STREAM_ID = 0;
public static final int PSR_PRIMARY_AUDIO_ID = 1;
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index f107e86..03c130a 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -1136,7 +1136,7 @@ static int _start_bdj(BLURAY *bd, unsigned title)
return 0;
}
}
- return bdj_start(bd->bdjava, title);
+ return !bdj_process_event(bd->bdjava, BDJ_EVENT_START, title);
#else
BD_DEBUG(DBG_BLURAY | DBG_CRIT, "Title %d: BD-J not compiled in\n", title);
return 0;
@@ -1159,7 +1159,7 @@ static int _bdj_event(BLURAY *bd, unsigned ev, unsigned param)
static void _stop_bdj(BLURAY *bd)
{
if (bd->bdjava != NULL) {
- bdj_stop(bd->bdjava);
+ bdj_process_event(bd->bdjava, BDJ_EVENT_STOP, 0);
}
}
#else
More information about the libbluray-devel
mailing list