[vlc-commits] gl: cvpx: use CVEAGLContextCGLContextObj from ios vout variable

Thomas Guillem git at videolan.org
Tue Sep 12 16:48:43 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Sep 12 14:53:28 2017 +0200| [17cc36260ab43cf415ad80a9f56da88b2ccbd896] | committer: Thomas Guillem

gl: cvpx: use CVEAGLContextCGLContextObj from ios vout variable

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=17cc36260ab43cf415ad80a9f56da88b2ccbd896
---

 modules/video_output/ios.m                   |  9 ++++++---
 modules/video_output/opengl/converter_cvpx.c | 14 ++++++++------
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index c1a8157c5e..84abf91b7d 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -128,7 +128,6 @@ struct vout_display_sys_t
 
 struct gl_sys
 {
-    CVEAGLContext locked_ctx;
     VLCOpenGLES2VideoView *glESView;
 };
 
@@ -155,6 +154,8 @@ static int Open(vlc_object_t *this)
     sys->picturePool = NULL;
     sys->gl = NULL;
 
+    var_Create(vd->obj.parent, "ios-eaglcontext", VLC_VAR_ADDRESS);
+
     @autoreleasepool {
         /* setup the actual OpenGL ES view */
         [VLCOpenGLES2VideoView performSelectorOnMainThread:@selector(getNewView:)
@@ -184,7 +185,6 @@ static int Open(vlc_object_t *this)
             vlc_malloc(this, sizeof(struct gl_sys));
         if (unlikely(!sys->gl->sys))
             goto bailout;
-        glsys->locked_ctx = NULL;
         glsys->glESView = sys->glESView;
         /* Initialize common OpenGL video display */
         sys->gl->makeCurrent = OpenglESLock;
@@ -194,6 +194,9 @@ static int Open(vlc_object_t *this)
 
         if (vlc_gl_MakeCurrent(sys->gl) != VLC_SUCCESS)
             goto bailout;
+
+        var_SetAddress(vd->obj.parent, "ios-eaglcontext", [sys->glESView eaglContext]);
+
         sys->vgl = vout_display_opengl_New(&vd->fmt, &subpicture_chromas,
                                            sys->gl, &vd->cfg->viewpoint);
         vlc_gl_ReleaseCurrent(sys->gl);
@@ -270,6 +273,7 @@ static void Close (vlc_object_t *this)
 
         [sys->glESView release];
     }
+    var_Destroy(vd->obj.parent, "ios-eaglcontext");
 }
 
 /*****************************************************************************
@@ -396,7 +400,6 @@ static int OpenglESLock(vlc_gl_t *gl)
 
     [sys->glESView lock];
     [sys->glESView resetBuffers];
-    sys->locked_ctx = (__bridge CVEAGLContext) ((__bridge void *) [sys->glESView eaglContext]);
     return VLC_SUCCESS;
 }
 
diff --git a/modules/video_output/opengl/converter_cvpx.c b/modules/video_output/opengl/converter_cvpx.c
index dc5313ccec..886dcd616f 100644
--- a/modules/video_output/opengl/converter_cvpx.c
+++ b/modules/video_output/opengl/converter_cvpx.c
@@ -29,10 +29,6 @@
 #include <OpenGLES/ES2/gl.h>
 #include <OpenGLES/ES2/glext.h>
 #include <CoreVideo/CVOpenGLESTextureCache.h>
-struct gl_sys
-{
-    CVEAGLContext locked_ctx;
-};
 #else
 #include <IOSurface/IOSurface.h>
 #endif
@@ -174,10 +170,16 @@ Open(vlc_object_t *obj)
     const GLenum tex_target = GL_TEXTURE_2D;
 
     {
-        struct gl_sys *glsys = tc->gl->sys;
+        CVEAGLContext eagl_ctx = var_InheritAddress(tc->gl, "ios-eaglcontext");
+        if (!eagl_ctx)
+        {
+            msg_Err(tc->gl, "can't find ios-eaglcontext\n");
+            free(priv);
+            return VLC_EGENERIC;
+        }
         CVReturn err =
             CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, NULL,
-                                         glsys->locked_ctx, NULL, &priv->cache);
+                                         eagl_ctx, NULL, &priv->cache);
         if (err != noErr)
         {
             msg_Err(tc->gl, "CVOpenGLESTextureCacheCreate failed: %d", err);



More information about the vlc-commits mailing list