Commit 1b454f51 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

readMedia: allocate/release string around the code that uses it

parent 5fb0e6a5
...@@ -338,16 +338,15 @@ jobjectArray Java_org_videolan_vlc_android_LibVLC_readMediaMeta(JNIEnv *env, ...@@ -338,16 +338,15 @@ jobjectArray Java_org_videolan_vlc_android_LibVLC_readMediaMeta(JNIEnv *env,
void Java_org_videolan_vlc_android_LibVLC_readMedia(JNIEnv *env, jobject thiz, void Java_org_videolan_vlc_android_LibVLC_readMedia(JNIEnv *env, jobject thiz,
jint instance, jstring mrl) jint instance, jstring mrl)
{ {
jboolean isCopy;
int i;
const char *psz_mrl = (*env)->GetStringUTFChars(env, mrl, &isCopy);
/* Release previous media player, if any */ /* Release previous media player, if any */
releaseMediaPlayer(env, thiz); releaseMediaPlayer(env, thiz);
/* Create a new item */ /* Create a new item */
jboolean isCopy;
const char *psz_mrl = (*env)->GetStringUTFChars(env, mrl, &isCopy);
libvlc_media_t *m = libvlc_media_new_path((libvlc_instance_t*)instance, libvlc_media_t *m = libvlc_media_new_path((libvlc_instance_t*)instance,
psz_mrl); psz_mrl);
(*env)->ReleaseStringUTFChars(env, mrl, psz_mrl);
/* Create a media player playing environment */ /* Create a media player playing environment */
libvlc_media_player_t *mp = libvlc_media_player_new((libvlc_instance_t*)instance); libvlc_media_player_t *mp = libvlc_media_player_new((libvlc_instance_t*)instance);
...@@ -371,6 +370,7 @@ void Java_org_videolan_vlc_android_LibVLC_readMedia(JNIEnv *env, jobject thiz, ...@@ -371,6 +370,7 @@ void Java_org_videolan_vlc_android_LibVLC_readMedia(JNIEnv *env, jobject thiz,
/* Subscribe to the events */ /* Subscribe to the events */
int i;
for (i = 0; i < (sizeof(mp_events) / sizeof(*mp_events)); ++i) for (i = 0; i < (sizeof(mp_events) / sizeof(*mp_events)); ++i)
libvlc_event_attach(ev, mp_events[i], vlc_event_callback, myVm); libvlc_event_attach(ev, mp_events[i], vlc_event_callback, myVm);
...@@ -384,8 +384,6 @@ void Java_org_videolan_vlc_android_LibVLC_readMedia(JNIEnv *env, jobject thiz, ...@@ -384,8 +384,6 @@ void Java_org_videolan_vlc_android_LibVLC_readMedia(JNIEnv *env, jobject thiz,
libvlc_media_player_play(mp); libvlc_media_player_play(mp);
//libvlc_media_player_release(mp); //libvlc_media_player_release(mp);
(*env)->ReleaseStringUTFChars(env, mrl, psz_mrl);
} }
jboolean Java_org_videolan_vlc_android_LibVLC_hasVideoTrack(JNIEnv *env, jobject thiz, jboolean Java_org_videolan_vlc_android_LibVLC_hasVideoTrack(JNIEnv *env, jobject thiz,
......
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