[Android] LibVLC: AWindow: create the Surface earlier

Thomas Guillem git at videolan.org
Mon Dec 16 11:50:29 CET 2019


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Dec 16 11:29:16 2019 +0100| [bd704a18d91f2fd720f33db22e39a0bea623a3e8] | committer: Thomas Guillem

LibVLC: AWindow: create the Surface earlier

On VLC 4.0, the Surface need to be created (from any threads) before being
attached.

> https://code.videolan.org/videolan/vlc-android/commit/bd704a18d91f2fd720f33db22e39a0bea623a3e8
---

 libvlc/src/org/videolan/libvlc/AWindow.java | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libvlc/src/org/videolan/libvlc/AWindow.java b/libvlc/src/org/videolan/libvlc/AWindow.java
index 1f08fc4f8..3ffcfeab3 100644
--- a/libvlc/src/org/videolan/libvlc/AWindow.java
+++ b/libvlc/src/org/videolan/libvlc/AWindow.java
@@ -582,7 +582,7 @@ public class AWindow implements IVLCVout {
         private SurfaceTextureThread() {
         }
 
-        private synchronized boolean attachToGLContext(int texName) {
+        private synchronized boolean createSurface() {
             /* Try to re-use the same SurfaceTexture until views are detached. By reusing the same
              * SurfaceTexture, we don't have to reconfigure MediaCodec when it signals a video size
              * change (and when a new VLC vout is created) */
@@ -599,6 +599,12 @@ public class AWindow implements IVLCVout {
                 }
                 mSurface = new Surface(mSurfaceTexture);
             }
+            return true;
+        }
+
+        private synchronized boolean attachToGLContext(int texName) {
+            if (!createSurface())
+                return false;
             mSurfaceTexture.attachToGLContext(texName);
             mFrameAvailable = false;
             mIsAttached = true;
@@ -677,6 +683,8 @@ public class AWindow implements IVLCVout {
         }
 
         private synchronized Surface getSurface() {
+            if (!createSurface())
+                return null;
             return mSurface;
         }
 



More information about the Android mailing list