Bug 1316010 - org.webrtc.videoengine.ViEAndroidGLES20.onDrawFrame(GL10) does not release lock on all paths r?sebastian draft
authorTomislav Jurin <svezauzeto12@hotmail.com>
Mon, 19 Dec 2016 20:54:30 +0100
changeset 451162 a442dd097cb60d445ce82ebaf60f160122284ed6
parent 445542 4492b145f855a1f271eb3e2a7a50c3257ae94446
child 539944 bd962642baaeab392a798c3350771a03c932b426
push id39072
push userbmo:svezauzeto12@hotmail.com
push dateMon, 19 Dec 2016 19:55:26 +0000
reviewerssebastian
bugs1316010
milestone53.0a1
Bug 1316010 - org.webrtc.videoengine.ViEAndroidGLES20.onDrawFrame(GL10) does not release lock on all paths r?sebastian MozReview-Commit-ID: 2NSgRaLvZH2
media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViEAndroidGLES20.java
--- a/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViEAndroidGLES20.java
+++ b/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/ViEAndroidGLES20.java
@@ -311,31 +311,32 @@ public class ViEAndroidGLES20 extends GL
         if(info.reqGlEsVersion >= 0x20000) {
             // Open GL ES 2.0 is supported.
             return true;
         }
         return false;
     }
 
     public void onDrawFrame(GL10 gl) {
-        nativeFunctionLock.lock();
-        if(!nativeFunctionsRegisted || !surfaceCreated) {
-            nativeFunctionLock.unlock();
-            return;
-        }
+        try {
+            nativeFunctionLock.lock();
+            if (!nativeFunctionsRegisted || !surfaceCreated) {
+                return;
+            }
 
-        if(!openGLCreated) {
-            if(0 != CreateOpenGLNative(nativeObject, viewWidth, viewHeight)) {
-                nativeFunctionLock.unlock();
-                return; // Failed to create OpenGL
+            if (!openGLCreated) {
+                if (0 != CreateOpenGLNative(nativeObject, viewWidth, viewHeight)) {
+                    return; // Failed to create OpenGL
+                }
+                openGLCreated = true; // Created OpenGL successfully
             }
-            openGLCreated = true; // Created OpenGL successfully
+            DrawNative(nativeObject); // Draw the new frame
+        } finally {
+            nativeFunctionLock.unlock();
         }
-        DrawNative(nativeObject); // Draw the new frame
-        nativeFunctionLock.unlock();
     }
 
     public void onSurfaceChanged(GL10 gl, int width, int height) {
         surfaceCreated = true;
         viewWidth = width;
         viewHeight = height;
 
         nativeFunctionLock.lock();