[Android] Rewrite PathToURI in java-only
Jean-Baptiste Kempf
git at videolan.org
Thu May 28 11:57:50 CEST 2015
vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu May 28 11:56:22 2015 +0200| [a0ed0dd8bc35da54f949f95f9b6b62394a62ca8f] | committer: Jean-Baptiste Kempf
Rewrite PathToURI in java-only
This avoids context switches and cleans the code
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=a0ed0dd8bc35da54f949f95f9b6b62394a62ca8f
---
libvlc/jni/libvlcjni-util.c | 19 -------------------
libvlc/src/org/videolan/libvlc/LibVLC.java | 7 ++++---
2 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/libvlc/jni/libvlcjni-util.c b/libvlc/jni/libvlcjni-util.c
index 9ca4e2b..18e8ba6 100644
--- a/libvlc/jni/libvlcjni-util.c
+++ b/libvlc/jni/libvlcjni-util.c
@@ -138,25 +138,6 @@ jobject getEventHandlerReference(JNIEnv *env, jobject thiz, jobject eventHandler
return (*env)->NewGlobalRef(env, eventHandler);
}
-jstring Java_org_videolan_libvlc_LibVLC_nativeToURI(JNIEnv *env, jobject thiz, jstring path)
-{
- jboolean isCopy;
- /* Get C string */
- const char* psz_path = (*env)->GetStringUTFChars(env, path, &isCopy);
- /* Convert the path to URI */
- char* psz_location;
- if(unlikely( strstr( psz_path, "://" ) ))
- psz_location = strdup(psz_path);
- else
- psz_location = vlc_path2uri(psz_path, "file");
- /* Box into jstring */
- jstring t = (*env)->NewStringUTF(env, psz_location);
- /* Clean up */
- (*env)->ReleaseStringUTFChars(env, path, psz_path);
- free(psz_location);
- return t;
-}
-
void Java_org_videolan_libvlc_LibVLC_nativeReadDirectory(JNIEnv *env, jobject thiz, jstring path, jobject arrayList)
{
jboolean isCopy;
diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index c9e0987..22b559b 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -21,6 +21,7 @@
package org.videolan.libvlc;
import java.io.File;
+import java.net.URI;
import java.util.ArrayList;
import android.content.Context;
@@ -498,8 +499,6 @@ public class LibVLC {
* @return a bytearray with the RGBA thumbnail data inside.
*/
public native byte[] getThumbnail(String mrl, int i_width, int i_height);
-
- public static native String nativeToURI(String path);
public native static void sendMouseEvent( int action, int button, int x, int y);
@@ -514,7 +513,9 @@ public class LibVLC {
if(path == null) {
throw new NullPointerException("Cannot convert null path!");
}
- return LibVLC.nativeToURI(path);
+
+ File f = new File(path);
+ return f.toURI().toString();
}
public static native void nativeReadDirectory(String path, ArrayList<String> res);
More information about the Android
mailing list