[vlc-commits] vout iOS: fix context initialization if someone else already created a context

Felix Paul Kühne git at videolan.org
Sat Oct 14 18:22:23 CEST 2017


vlc | branch: master | Felix Paul Kühne <felix at serioese.gmbh> | Fri Oct 13 16:36:58 2017 +0200| [a4b01f928a59353106cd82cb06c306c31bcbddba] | committer: Felix Paul Kühne

vout iOS: fix context initialization if someone else already created a context

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

 modules/video_output/ios.m | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index deeb2640eb..611e4f6813 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -448,6 +448,12 @@ static void OpenglESSwap(vlc_gl_t *gl)
     if (unlikely(!_appActive))
         return nil;
 
+    /* the following creates a new OpenGL ES context with the API version we
+     * need if there is already an active context created by another OpenGL
+     * provider we cache it and restore analog to the lock/unlock pattern used
+     * through-out the class */
+    _previousEaglContext = [EAGLContext currentContext];
+
     _eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
 
     if (unlikely(!_eaglContext))
@@ -461,6 +467,8 @@ static void OpenglESSwap(vlc_gl_t *gl)
 
     self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
 
+    [self unlock];
+
     return self;
 }
 
@@ -640,8 +648,7 @@ static void OpenglESSwap(vlc_gl_t *gl)
         return;
     }
 
-    EAGLContext *previousContext = [EAGLContext currentContext];
-    [EAGLContext setCurrentContext:_eaglContext];
+    [self lock]
 
     CGSize viewSize = [self bounds].size;
     CGFloat scaleFactor = self.contentScaleFactor;
@@ -661,7 +668,7 @@ static void OpenglESSwap(vlc_gl_t *gl)
 
     // x / y are top left corner, but we need the lower left one
     glViewport(place.x, place.y, place.width, place.height);
-    [EAGLContext setCurrentContext:previousContext];
+    [self unlock];
 }
 
 - (void)tapRecognized:(UITapGestureRecognizer *)tapRecognizer



More information about the vlc-commits mailing list