[libbluray-devel] bd_user_input(): return -1 if key is not handled in BD-J
hpi1
git at videolan.org
Tue May 7 08:38:57 CEST 2013
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed May 1 21:19:38 2013 +0300| [e0ab48812b43e1064bec43d3c21bc6308e6d0ef6] | committer: hpi1
bd_user_input(): return -1 if key is not handled in BD-J
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=e0ab48812b43e1064bec43d3c21bc6308e6d0ef6
---
src/libbluray/bdj/bdj.c | 13 +++++++++----
src/libbluray/bdj/bdj.h | 2 +-
src/libbluray/bdj/java/java/awt/BDJHelper.java | 6 ++++--
.../bdj/java/org/dvb/event/EventManager.java | 16 ++++++++++++----
src/libbluray/bdj/java/org/videolan/Libbluray.java | 20 +++++++++++++++-----
src/libbluray/bluray.c | 10 +++++-----
6 files changed, 46 insertions(+), 21 deletions(-)
diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index a3693a5..b5bdc41 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -469,7 +469,7 @@ void bdj_close(BDJAVA *bdjava)
X_FREE(bdjava);
}
-void bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param)
+int bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param)
{
static const char * const ev_name[] = {
"NONE",
@@ -488,9 +488,10 @@ void bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param)
int attach = 0;
jclass event_class;
jmethodID event_id;
+ int result = -1;
if (!bdjava) {
- return;
+ return -1;
}
BD_DEBUG(DBG_BDJ, "bdj_process_event(%s,%d)\n", ev_name[ev], param);
@@ -501,8 +502,10 @@ void bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param)
}
if (bdj_get_method(env, &event_class, &event_id,
- "org/videolan/Libbluray", "processEvent", "(II)V")) {
- (*env)->CallStaticVoidMethod(env, event_class, event_id, ev, param);
+ "org/videolan/Libbluray", "processEvent", "(II)Z")) {
+ if ((*env)->CallStaticBooleanMethod(env, event_class, event_id, ev, param)) {
+ result = 0;
+ }
if ((*env)->ExceptionOccurred(env)) {
(*env)->ExceptionDescribe(env);
@@ -515,4 +518,6 @@ void bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param)
if (attach) {
(*bdjava->jvm)->DetachCurrentThread(bdjava->jvm);
}
+
+ return result;
}
diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h
index 2da2825..5ce5ecb 100644
--- a/src/libbluray/bdj/bdj.h
+++ b/src/libbluray/bdj/bdj.h
@@ -53,6 +53,6 @@ BD_PRIVATE BDJAVA* bdj_open(const char *path, struct bluray *bd,
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 void bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param);
+BD_PRIVATE int bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param);
#endif
diff --git a/src/libbluray/bdj/java/java/awt/BDJHelper.java b/src/libbluray/bdj/java/java/awt/BDJHelper.java
index 1b194a9..8bb2edd 100644
--- a/src/libbluray/bdj/java/java/awt/BDJHelper.java
+++ b/src/libbluray/bdj/java/java/awt/BDJHelper.java
@@ -68,7 +68,7 @@ public class BDJHelper {
}
}
- public static void postKeyEvent(int id, int modifiers, int keyCode) {
+ public static boolean postKeyEvent(int id, int modifiers, int keyCode) {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getGlobalFocusOwner();
if (focusOwner != null) {
long when = System.currentTimeMillis();
@@ -79,12 +79,14 @@ public class BDJHelper {
else
event = new KeyEvent(focusOwner, id, when, modifiers, keyCode, KeyEvent.CHAR_UNDEFINED);
BDToolkit.getEventQueue(focusOwner).postEvent(event);
- return;
+ return true;
} catch (Throwable e) {
org.videolan.Logger.getLogger("BDJHelper").error("postKeyEvent failed: " + e);
}
} else {
org.videolan.Logger.getLogger("BDJHelper").error("*** KEY event dropped ***");
}
+
+ return false;
}
}
diff --git a/src/libbluray/bdj/java/org/dvb/event/EventManager.java b/src/libbluray/bdj/java/org/dvb/event/EventManager.java
index a1312b2..aa67327 100644
--- a/src/libbluray/bdj/java/org/dvb/event/EventManager.java
+++ b/src/libbluray/bdj/java/org/dvb/event/EventManager.java
@@ -127,7 +127,12 @@ public class EventManager implements ResourceServer {
}
public void receiveKeyEvent(int type, int modifiers, int keyCode) {
+ receiveKeyEventN(type, modifiers, keyCode);
+ }
+
+ public boolean receiveKeyEventN(int type, int modifiers, int keyCode) {
HScene focusHScene = GUIManager.getInstance().getFocusHScene();
+ boolean result = false;
if (focusHScene != null) {
XletContext context = focusHScene.getXletContext();
for (Iterator it = exclusiveAWTEventListener.iterator(); it.hasNext(); ) {
@@ -141,8 +146,8 @@ public class EventManager implements ResourceServer {
(evt.getCode() == keyCode) &&
(evt.getType() == type)) {
- BDJHelper.postKeyEvent(type, modifiers, keyCode);
- return;
+ result = BDJHelper.postKeyEvent(type, modifiers, keyCode);
+ return result;
}
}
}
@@ -159,12 +164,12 @@ public class EventManager implements ResourceServer {
(evt.getType() == type)) {
BDJActionManager.getInstance().putCallback(new UserEventAction(item, i));
- return;
+ return true;
}
}
}
- BDJHelper.postKeyEvent(type, modifiers, keyCode);
+ result = BDJHelper.postKeyEvent(type, modifiers, keyCode);
for (Iterator it = sharedUserEventListener.iterator(); it.hasNext(); ) {
UserEventItem item = (UserEventItem)it.next();
@@ -175,9 +180,12 @@ public class EventManager implements ResourceServer {
(evt.getCode() == keyCode) &&
(evt.getType() == type)) {
BDJActionManager.getInstance().putCallback(new UserEventAction(item, i));
+ result = true;
}
}
}
+
+ return result;
}
private boolean cleanupReservedEvents(UserEventRepository userEvents) {
diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index 0afab9b..a33f3ad 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -310,8 +310,10 @@ public class Libbluray {
x0, y0, x1, y1);
}
- public static void processEvent(int event, int param) {
+ public static boolean processEvent(int event, int param) {
+ boolean result = true;
int key = 0;
+
switch (event) {
case BDJ_EVENT_CHAPTER:
BDHandler.onChapterReach(param);
@@ -358,15 +360,23 @@ public class Libbluray {
case 14: key = KeyEvent.VK_LEFT; break;
case 15: key = KeyEvent.VK_RIGHT; break;
case 16: key = KeyEvent.VK_ENTER; break;
- default: key = -1; break;
+ default:
+ key = -1;
+ result = false;
+ break;
}
if (key > 0) {
- EventManager.getInstance().receiveKeyEvent(KeyEvent.KEY_PRESSED, 0, key);
- EventManager.getInstance().receiveKeyEvent(KeyEvent.KEY_RELEASED, 0, key);
- EventManager.getInstance().receiveKeyEvent(KeyEvent.KEY_TYPED, 0, key);
+ result =
+ EventManager.getInstance().receiveKeyEventN(KeyEvent.KEY_PRESSED, 0, key) ||
+ EventManager.getInstance().receiveKeyEventN(KeyEvent.KEY_RELEASED, 0, key) ||
+ EventManager.getInstance().receiveKeyEventN(KeyEvent.KEY_TYPED, 0, key);
}
break;
+ default:
+ result = false;
}
+
+ return result;
}
private static final int BDJ_EVENT_CHAPTER = 1;
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 7351c75..2e794a7 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -1226,14 +1226,15 @@ static int _start_bdj(BLURAY *bd, unsigned title)
}
#ifdef USING_BDJAVA
-static void _bdj_event(BLURAY *bd, unsigned ev, unsigned param)
+static int _bdj_event(BLURAY *bd, unsigned ev, unsigned param)
{
if (bd->bdjava != NULL) {
- bdj_process_event(bd->bdjava, ev, param);
+ return bdj_process_event(bd->bdjava, ev, param);
}
+ return -1;
}
#else
-#define _bdj_event(bd, ev, param) do{}while(0)
+#define _bdj_event(bd, ev, param) (bd=bd, -1)
#endif
static void _stop_bdj(BLURAY *bd)
@@ -3014,8 +3015,7 @@ int bd_user_input(BLURAY *bd, int64_t pts, uint32_t key)
if (bd->title_type == title_hdmv) {
result = _run_gc(bd, GC_CTRL_VK_KEY, key);
} else if (bd->title_type == title_bdj) {
- _bdj_event(bd, BDJ_EVENT_VK_KEY, key);
- result = 0;
+ result = _bdj_event(bd, BDJ_EVENT_VK_KEY, key);
}
bd_mutex_unlock(&bd->mutex);
More information about the libbluray-devel
mailing list