[vlc-commits] vout/ios: Simplify makeCurrentWithGL:withGL:

Marvin Scholz git at videolan.org
Wed Jan 23 19:56:53 CET 2019


vlc/vlc-3.0 | branch: master | Marvin Scholz <epirat07 at gmail.com> | Fri Jan 18 18:52:37 2019 +0100| [dc771027addbc637cedb82dd19f02e77d8e9f5eb] | committer: Felix Paul Kühne

vout/ios: Simplify makeCurrentWithGL:withGL:

Return early when setCurrentContext fails, this simplifies
the following code and makes it much easier to read.

Signed-off-by: Thomas Guillem <thomas at gllm.fr>
(cherry picked from commit f9c4af6e89c9dca6bbe92b14623b74621976cd25)

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

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

diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index 1ea2ee45aa..f4af41beb5 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -607,14 +607,19 @@ static void GLESSwap(vlc_gl_t *gl)
         vlc_mutex_unlock(&_mutex);
         return NO;
     }
-    assert(_eaglEnabled);
 
+    assert(_eaglEnabled);
     *previousEaglContext = [EAGLContext currentContext];
 
-    BOOL success = [EAGLContext setCurrentContext:_eaglContext];
+    if (![EAGLContext setCurrentContext:_eaglContext])
+    {
+        vlc_mutex_unlock(&_mutex);
+        return NO;
+    }
+
     BOOL resetBuffers = NO;
 
-    if (success && gl != NULL)
+    if (gl != NULL)
     {
         struct gl_sys *glsys = gl->sys;
 
@@ -636,8 +641,7 @@ static void GLESSwap(vlc_gl_t *gl)
         }
     }
 
-    if (success)
-        _gl_attached = YES;
+    _gl_attached = YES;
 
     vlc_mutex_unlock(&_mutex);
 
@@ -646,7 +650,7 @@ static void GLESSwap(vlc_gl_t *gl)
         [self releaseCurrent:*previousEaglContext];
         return NO;
     }
-    return success;
+    return YES;
 }
 
 - (void)releaseCurrent:(EAGLContext *)previousEaglContext



More information about the vlc-commits mailing list