Bug 1316010 - fixing org.webrtc.videoengine.ViEAndroidGLES20.onDrawFrame(GL10) does not release lock on all paths r?sebastian draft
authorTomislav Jurin <svezauzeto12@hotmail.com>
Tue, 20 Dec 2016 22:18:06 +0100
changeset 451682 dedd11d21ff6b523745053ab1a30858e0d3baeaf
parent 446051 361e2162638178701caa2a229b008d1220520d9c
child 540096 7b6df27ace0fe9984920ce1f86e2bf1659bf7b8f
push id39255
push userbmo:svezauzeto12@hotmail.com
push dateTue, 20 Dec 2016 21:18:56 +0000
reviewerssebastian
bugs1316010
milestone53.0a1
Bug 1316010 - fixing org.webrtc.videoengine.ViEAndroidGLES20.onDrawFrame(GL10) does not release lock on all paths r?sebastian MozReview-Commit-ID: 3zsVdgVZHQa
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,30 +311,33 @@ 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)) {
-                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();