[Android] Add a function for getting the java Surface object

Martin Storsjö git at videolan.org
Fri Jul 26 11:54:06 CEST 2013


vlc-ports/android | branch: master | Martin Storsjö <martin at martin.st> | Mon Feb 18 00:15:02 2013 +0200| [b3a73af59e6914ef2918899b845aaa9d92ac88d1] | committer: Martin Storsjö

Add a function for getting the java Surface object

Signed-off-by: Martin Storsjö <martin at martin.st>

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

 vlc-android/jni/libvlcjni.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index d9a6036..8926517 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -203,12 +203,18 @@ static jobject debugBufferInstance = NULL;
 static pthread_mutex_t vout_android_lock;
 static void *vout_android_surf = NULL;
 static void *vout_android_gui = NULL;
+static jobject vout_android_java_surf = NULL;
 
 void *jni_LockAndGetAndroidSurface() {
     pthread_mutex_lock(&vout_android_lock);
     return vout_android_surf;
 }
 
+jobject jni_LockAndGetAndroidJavaSurface() {
+    pthread_mutex_lock(&vout_android_lock);
+    return vout_android_java_surf;
+}
+
 void jni_UnlockAndroidSurface() {
     pthread_mutex_unlock(&vout_android_lock);
 }
@@ -346,6 +352,7 @@ void Java_org_videolan_libvlc_LibVLC_attachSurface(JNIEnv *env, jobject thiz, jo
     (*env)->DeleteLocalRef(env, clz);
 
     vout_android_gui = (*env)->NewGlobalRef(env, gui);
+    vout_android_java_surf = (*env)->NewGlobalRef(env, surf);
     pthread_mutex_unlock(&vout_android_lock);
 }
 
@@ -354,7 +361,10 @@ void Java_org_videolan_libvlc_LibVLC_detachSurface(JNIEnv *env, jobject thiz) {
     vout_android_surf = NULL;
     if (vout_android_gui != NULL)
         (*env)->DeleteGlobalRef(env, vout_android_gui);
+    if (vout_android_java_surf != NULL)
+        (*env)->DeleteGlobalRef(env, vout_android_java_surf);
     vout_android_gui = NULL;
+    vout_android_java_surf = NULL;
     pthread_mutex_unlock(&vout_android_lock);
 }
 



More information about the Android mailing list