Bug 1316010 - fixing org.webrtc.videoengine.ViEAndroidGLES20.onDrawFrame(GL10) does not release lock on all paths r?sebastian
MozReview-Commit-ID: 3zsVdgVZHQa
--- 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();