[Android] libvlcjni: jni_LockAndGetSubtitlesSurface returns immediatly

Thomas Guillem git at videolan.org
Thu Apr 9 17:43:36 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Apr  8 17:25:01 2015 +0200| [55bfe1aed2e05e600d8266ca4cad0bc746312f70] | committer: Thomas Guillem

libvlcjni: jni_LockAndGetSubtitlesSurface returns immediatly

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=55bfe1aed2e05e600d8266ca4cad0bc746312f70
---

 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..fa6912f 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_unlock(&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_unlock(&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);
 }
 



More information about the Android mailing list