Commit 55e9a09e authored by Thomas Guillem's avatar Thomas Guillem

LibVLC: add second long argument in Events

parent 415e80cb
......@@ -78,10 +78,10 @@ MediaPlayer_event_cb(vlcjni_object *p_obj, const libvlc_event_t *p_ev,
switch (p_ev->type)
{
case libvlc_MediaPlayerBuffering:
p_java_event->arg2 = p_ev->u.media_player_buffering.new_cache;
p_java_event->argf1 = p_ev->u.media_player_buffering.new_cache;
break;
case libvlc_MediaPlayerPositionChanged:
p_java_event->arg2 = p_ev->u.media_player_position_changed.new_position;
p_java_event->argf1 = p_ev->u.media_player_position_changed.new_position;
break;
case libvlc_MediaPlayerTimeChanged:
p_java_event->arg1 = p_ev->u.media_player_time_changed.new_time;
......
......@@ -171,14 +171,11 @@ static void
VLCJniObject_eventCallback(const libvlc_event_t *ev, void *data)
{
vlcjni_object *p_obj = data;
java_event jevent;
JNIEnv *env = NULL;
assert(p_obj->p_libvlc);
jevent.type = -1;
jevent.arg1 = 0;
jevent.arg2 = 0.0;
java_event jevent = { -1, 0, 0, 0.0 };
if (!p_obj->p_owner->pf_event_cb(p_obj, ev, &jevent))
return;
......@@ -189,12 +186,14 @@ VLCJniObject_eventCallback(const libvlc_event_t *ev, void *data)
if (p_obj->p_owner->weak)
(*env)->CallVoidMethod(env, p_obj->p_owner->weak,
fields.VLCObject.dispatchEventFromNativeID,
jevent.type, jevent.arg1, jevent.arg2);
jevent.type, jevent.arg1, jevent.arg2,
jevent.argf1);
else
(*env)->CallStaticVoidMethod(env, fields.VLCObject.clazz,
fields.VLCObject.dispatchEventFromWeakNativeID,
p_obj->p_owner->weakCompat,
jevent.type, jevent.arg1, jevent.arg2);
jevent.type, jevent.arg1, jevent.arg2,
jevent.argf1);
}
void
......
......@@ -60,7 +60,8 @@ struct java_event
{
jint type;
jlong arg1;
jfloat arg2;
jlong arg2;
jfloat argf1;
};
/* event manager callback dispatched to native struct implementing a
......
......@@ -198,7 +198,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
GET_ID(GetMethodID,
fields.VLCObject.dispatchEventFromNativeID,
fields.VLCObject.clazz,
"dispatchEventFromNative", "(IJF)V");
"dispatchEventFromNative", "(IJJF)V");
if (fields.SDK_INT <= 13)
{
......@@ -210,7 +210,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
GET_ID(GetStaticMethodID,
fields.VLCObject.dispatchEventFromWeakNativeID,
fields.VLCObject.clazz,
"dispatchEventFromWeakNative", "(Ljava/lang/Object;IJF)V");
"dispatchEventFromWeakNative", "(Ljava/lang/Object;IJJF)V");
} else
{
fields.VLCObject.getWeakReferenceID = NULL;
......
......@@ -119,7 +119,7 @@ public class LibVLC extends VLCObject<LibVLC.Event> {
public native String changeset();
@Override
protected Event onEventNative(int eventType, long arg1, float arg2) {
protected Event onEventNative(int eventType, long arg1, long arg2, float argf1) {
return null;
}
......
......@@ -474,7 +474,7 @@ public class Media extends VLCObject<Media.Event> {
}
@Override
protected synchronized Event onEventNative(int eventType, long arg1, float arg2) {
protected synchronized Event onEventNative(int eventType, long arg1, long arg2, float argf1) {
switch (eventType) {
case Event.MetaChanged:
// either we update all metas (if first call) or we update a specific meta
......
......@@ -106,7 +106,7 @@ public class MediaDiscoverer extends VLCObject<MediaDiscoverer.Event> {
}
@Override
protected Event onEventNative(int eventType, long arg1, float arg2) {
protected Event onEventNative(int eventType, long arg1, long arg2, float argf1) {
switch (eventType) {
case Event.Started:
case Event.Ended:
......
......@@ -121,7 +121,7 @@ public class MediaList extends VLCObject<MediaList.Event> {
}
@Override
protected synchronized Event onEventNative(int eventType, long arg1, float arg2) {
protected synchronized Event onEventNative(int eventType, long arg1, long arg2, float argf1) {
if (mLocked)
throw new IllegalStateException("already locked from event callback");
mLocked = true;
......
......@@ -75,15 +75,20 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
protected Event(int type, long arg1) {
super(type, arg1);
}
protected Event(int type, float arg2) {
super(type, arg2);
protected Event(int type, long arg1, long arg2) {
super(type, arg1, arg2);
}
protected Event(int type, float argf) {
super(type, argf);
}
public long getTimeChanged() {
return arg1;
}
public float getPositionChanged() {
return arg2;
return argf1;
}
public int getVoutCount() {
return (int) arg1;
......@@ -98,7 +103,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
return arg1 != 0;
}
public float getBuffering() {
return arg2;
return argf1;
}
}
......@@ -1077,7 +1082,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
}
@Override
protected synchronized Event onEventNative(int eventType, long arg1, float arg2) {
protected synchronized Event onEventNative(int eventType, long arg1, long arg2, float argf1) {
switch (eventType) {
case Event.MediaChanged:
case Event.Stopped:
......@@ -1087,14 +1092,14 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
notify();
case Event.Opening:
case Event.Buffering:
return new Event(eventType, arg2);
return new Event(eventType, argf1);
case Event.Playing:
case Event.Paused:
return new Event(eventType);
case Event.TimeChanged:
return new Event(eventType, arg1);
case Event.PositionChanged:
return new Event(eventType, arg2);
return new Event(eventType, argf1);
case Event.Vout:
mVoutCount = (int) arg1;
notify();
......
......@@ -23,22 +23,30 @@ package org.videolan.libvlc;
abstract class VLCEvent {
public final int type;
protected final long arg1;
protected final float arg2;
protected final long arg2;
protected final float argf1;
protected VLCEvent(int type) {
this.type = type;
this.arg1 = 0;
this.arg2 = 0;
this.arg1 = this.arg2 = 0;
this.argf1 = 0.0f;
}
protected VLCEvent(int type, long arg1) {
this.type = type;
this.arg1 = arg1;
this.arg2 = 0;
this.argf1 = 0.0f;
}
protected VLCEvent(int type, float arg2) {
protected VLCEvent(int type, long arg1, long arg2) {
this.type = type;
this.arg1 = 0;
this.arg1 = arg1;
this.arg2 = arg2;
this.argf1 = 0.0f;
}
protected VLCEvent(int type, float argf) {
this.type = type;
this.arg1 = this.arg2 = 0;
this.argf1 = argf;
}
/**
......
......@@ -122,9 +122,10 @@ abstract class VLCObject<T extends VLCEvent> {
* @param eventType event type
* @param arg1 first argument
* @param arg2 second argument
* @param argf1 first float argument
* @return Event that will be dispatched to listeners
*/
protected abstract T onEventNative(int eventType, long arg1, float arg2);
protected abstract T onEventNative(int eventType, long arg1, long arg2, float argf1);
/**
* Called when native object is released (refcount is 0).
......@@ -136,10 +137,10 @@ abstract class VLCObject<T extends VLCEvent> {
/* JNI */
@SuppressWarnings("unused") /* Used from JNI */
private long mInstance = 0;
private synchronized void dispatchEventFromNative(int eventType, long arg1, float arg2) {
private synchronized void dispatchEventFromNative(int eventType, long arg1, long arg2, float argf1) {
if (isReleased())
return;
final T event = onEventNative(eventType, arg1, arg2);
final T event = onEventNative(eventType, arg1, arg2, argf1);
class EventRunnable implements Runnable {
private final VLCEvent.Listener<T> listener;
......@@ -166,9 +167,10 @@ abstract class VLCObject<T extends VLCEvent> {
return new WeakReference<VLCObject>(this);
}
@SuppressWarnings("unchecked,unused") /* Used from JNI */
private static void dispatchEventFromWeakNative(Object weak, int eventType, long arg1, float arg2) {
private static void dispatchEventFromWeakNative(Object weak, int eventType, long arg1, long arg2,
float argf1) {
VLCObject obj = ((WeakReference<VLCObject>)weak).get();
if (obj != null)
obj.dispatchEventFromNative(eventType, arg1, arg2);
obj.dispatchEventFromNative(eventType, arg1, arg2, argf1);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment