Commit 88014c2c authored by Filippo Carone's avatar Filippo Carone

better args handling

parent 919c6542
...@@ -72,7 +72,10 @@ public class JVLC implements Runnable { ...@@ -72,7 +72,10 @@ public class JVLC implements Runnable {
} }
public JVLC(String[] args) { public JVLC(String[] args) {
_instance = createInstance( args ); String[] myargs = new String[args.length + 1];
myargs[0] = "jvlc";
System.arraycopy( args, 0, myargs, 1, args.length );
_instance = createInstance( myargs );
playlist = new Playlist ( _instance ); playlist = new Playlist ( _instance );
video = new Video ( _instance ); video = new Video ( _instance );
audio = new Audio ( _instance ); audio = new Audio ( _instance );
......
...@@ -56,11 +56,8 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env, ...@@ -56,11 +56,8 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env,
argc = (int) env->GetArrayLength((jarray) args) + 1; argc = (int) env->GetArrayLength((jarray) args) + 1;
argv = (const char **) malloc(argc * sizeof(char*)); argv = (const char **) malloc(argc * sizeof(char*));
argv[0] = "vlc"; for (int i = 0; i < argc; i++) {
argv[i] = env->GetStringUTFChars((jstring) env->GetObjectArrayElement(args, i),
for (int i = 0; i < argc - 1; i++) {
argv[i+1] = env->GetStringUTFChars((jstring) env->GetObjectArrayElement(args, i),
0 0
); );
} }
...@@ -68,8 +65,7 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env, ...@@ -68,8 +65,7 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env,
res = (long) libvlc_new(argc, (char**) argv, exception ); res = (long) libvlc_new(argc, (char**) argv, exception );
free( exception ); free( exception );
free( argv );
return res; return res;
} }
......
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