Commit 813cdff0 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Fix RendererItem created twice

parent ae523c0f
......@@ -197,22 +197,25 @@ error:
}
jobject
Java_org_videolan_libvlc_RendererItem_nativeNewItem(JNIEnv *env, jobject thiz, jobject rd,
Java_org_videolan_libvlc_RendererDiscoverer_nativeNewItem(JNIEnv *env, jobject thiz,
jlong ref)
{
vlcjni_object *p_rd_obj = VLCJniObject_getInstance(env, rd);
vlcjni_object *p_rd_obj = VLCJniObject_getInstance(env, thiz);
vlcjni_object *p_obj;
libvlc_renderer_item_t *item_ref = (libvlc_renderer_item_t *)(intptr_t)ref;
if (!p_rd_obj)
return NULL;
p_obj = VLCJniObject_newFromLibVlc(env, thiz, p_rd_obj->p_libvlc);
jobject jitem = item_to_object(env, item_ref);
p_obj = VLCJniObject_newFromLibVlc(env, jitem, p_rd_obj->p_libvlc);
if (!p_obj)
return NULL;
p_obj->u.p_r = libvlc_renderer_item_hold((libvlc_renderer_item_t *)ref);
p_obj->u.p_r = libvlc_renderer_item_hold(item_ref);
return item_to_object(env, p_obj->u.p_r);
return jitem;
}
void
......
......@@ -112,7 +112,7 @@ public class RendererDiscoverer extends VLCObject<RendererDiscoverer.Event> {
private final LongSparseArray<RendererItem> index = new LongSparseArray<>();
private synchronized RendererItem insertItemFromEvent(long arg1) {
final RendererItem item = new RendererItem(this, arg1);
final RendererItem item = nativeNewItem(arg1);
index.put(arg1, item);
return item;
}
......@@ -139,4 +139,5 @@ public class RendererDiscoverer extends VLCObject<RendererDiscoverer.Event> {
private native boolean nativeStart();
private native void nativeStop();
private static native Description[] nativeList(LibVLC libVLC);
private native RendererItem nativeNewItem(long ref);
}
......@@ -15,17 +15,6 @@ public class RendererItem extends VLCObject<RendererItem.Event> {
final int flags;
private final long ref;
RendererItem (RendererDiscoverer rd, long ref) {
super(rd);
final RendererItem item = nativeNewItem(rd, ref);
name = item == null ? null : item.name;
displayName = item == null ? null : item.displayName;
this.type = item == null ? null : item.type;
this.iconUrl = item == null ? null : item.iconUrl;
this.flags = item == null ? 0 : item.flags;
this.ref = item == null ? ref : item.ref;
}
RendererItem(String name, String type, String iconUrl, int flags, long ref) {
final int index = name.lastIndexOf('-');
this.name = name;
......@@ -57,6 +46,5 @@ public class RendererItem extends VLCObject<RendererItem.Event> {
}
}
private native RendererItem nativeNewItem(RendererDiscoverer rd, long ref);
private native void nativeReleaseItem();
}
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