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

hasVideoTrack: fix memleaks

parent 46b3e1a7
...@@ -296,7 +296,6 @@ void Java_org_videolan_vlc_android_LibVLC_setEventManager(JNIEnv *env, jobject t ...@@ -296,7 +296,6 @@ void Java_org_videolan_vlc_android_LibVLC_setEventManager(JNIEnv *env, jobject t
jobjectArray Java_org_videolan_vlc_android_LibVLC_readMediaMeta(JNIEnv *env, jobjectArray Java_org_videolan_vlc_android_LibVLC_readMediaMeta(JNIEnv *env,
jobject thiz, jint instance, jstring mrl) jobject thiz, jint instance, jstring mrl)
{ {
jboolean isCopy;
jobjectArray array = (*env)->NewObjectArray(env, 8, jobjectArray array = (*env)->NewObjectArray(env, 8,
(*env)->FindClass(env, "java/lang/String"), (*env)->FindClass(env, "java/lang/String"),
(*env)->NewStringUTF(env, "")); (*env)->NewStringUTF(env, ""));
...@@ -312,6 +311,7 @@ jobjectArray Java_org_videolan_vlc_android_LibVLC_readMediaMeta(JNIEnv *env, ...@@ -312,6 +311,7 @@ jobjectArray Java_org_videolan_vlc_android_LibVLC_readMediaMeta(JNIEnv *env,
libvlc_meta_Genre, libvlc_meta_Genre,
}; };
jboolean isCopy;
const char *psz_mrl = (*env)->GetStringUTFChars(env, mrl, &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);
...@@ -395,24 +395,32 @@ jboolean Java_org_videolan_vlc_android_LibVLC_hasVideoTrack(JNIEnv *env, jobject ...@@ -395,24 +395,32 @@ jboolean Java_org_videolan_vlc_android_LibVLC_hasVideoTrack(JNIEnv *env, jobject
/* Create a new item and assign it to the media player. */ /* Create a new item and assign it to the media player. */
libvlc_media_t *p_m = libvlc_media_new_path(p_instance, psz_filePath); libvlc_media_t *p_m = libvlc_media_new_path(p_instance, psz_filePath);
(*env)->ReleaseStringUTFChars(env, filePath, psz_filePath);
if (p_m == NULL) if (p_m == NULL)
{ {
LOGE("Couldn't create the media!"); LOGE("Couldn't create the media!");
return 0; return JNI_FALSE;
} }
/* Get the tracks information of the media. */ /* Get the tracks information of the media. */
libvlc_media_track_info_t *p_tracks; libvlc_media_track_info_t *p_tracks;
libvlc_media_parse(p_m); libvlc_media_parse(p_m);
int i_nbTracks = libvlc_media_get_tracks_info(p_m, &p_tracks);
jboolean hasVideo = JNI_FALSE;
int i_nbTracks = libvlc_media_get_tracks_info(p_m, &p_tracks);
unsigned i; unsigned i;
for (i = 0; i < i_nbTracks; ++i) for (i = 0; i < i_nbTracks; ++i)
{
if (p_tracks[i].i_type == libvlc_track_video) if (p_tracks[i].i_type == libvlc_track_video)
return 1; {
} hasVideo = JNI_TRUE;
return 0; break;
}
free(p_tracks);
libvlc_media_release(p_m);
return hasVideo;
} }
struct length_change_monitor { struct length_change_monitor {
......
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