[Android] [PATCH 1/3] libvlcjni: jni_LockAndGetSubtitlesSurface returns immediatly

Thomas Guillem thomas at gllm.fr
Wed Apr 8 17:30:16 CEST 2015


---
 libvlc/jni/vout.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libvlc/jni/vout.c b/libvlc/jni/vout.c
index a6928fd..19c2a73 100644
--- a/libvlc/jni/vout.c
+++ b/libvlc/jni/vout.c
@@ -27,7 +27,6 @@
 extern JNIEnv *jni_get_env(const char *name);
 
 pthread_mutex_t vout_android_lock;
-pthread_cond_t vout_android_surf_attached;
 static void *vout_android_gui = NULL;
 static jobject vout_android_java_surf = NULL;
 static jobject vout_android_subtitles_surf = NULL;
@@ -35,15 +34,19 @@ static bool vout_video_player_activity_created = false;
 
 void *jni_LockAndGetSubtitlesSurface() {
     pthread_mutex_lock(&vout_android_lock);
-    while (vout_android_subtitles_surf == NULL)
-        pthread_cond_wait(&vout_android_surf_attached, &vout_android_lock);
+    if (!vout_android_subtitles_surf) {
+        pthread_mutex_lock(&vout_android_lock);
+        return NULL;
+    }
     return vout_android_subtitles_surf;
 }
 
 jobject jni_LockAndGetAndroidJavaSurface() {
     pthread_mutex_lock(&vout_android_lock);
-    while (vout_android_java_surf == NULL)
-        pthread_cond_wait(&vout_android_surf_attached, &vout_android_lock);
+    if (!vout_android_java_surf) {
+        pthread_mutex_lock(&vout_android_lock);
+        return NULL;
+    }
     return vout_android_java_surf;
 }
 
@@ -181,7 +184,6 @@ void Java_org_videolan_libvlc_LibVLC_attachSurface(JNIEnv *env, jobject thiz, jo
         (*env)->DeleteGlobalRef(env, vout_android_java_surf);
     vout_android_gui = (*env)->NewGlobalRef(env, gui);
     vout_android_java_surf = (*env)->NewGlobalRef(env, surf);
-    pthread_cond_signal(&vout_android_surf_attached);
     pthread_mutex_unlock(&vout_android_lock);
 }
 
@@ -201,7 +203,6 @@ void Java_org_videolan_libvlc_LibVLC_attachSubtitlesSurface(JNIEnv *env, jobject
     if (vout_android_subtitles_surf != NULL)
         (*env)->DeleteGlobalRef(env, vout_android_subtitles_surf);
     vout_android_subtitles_surf = (*env)->NewGlobalRef(env, surf);
-    pthread_cond_signal(&vout_android_surf_attached);
     pthread_mutex_unlock(&vout_android_lock);
 }
 
-- 
2.1.3



More information about the Android mailing list