Android EGL: Synchronize calls to eglCreateContext

Synchronize calls to EGL10/EGL14.eglCreateContext on EglBase.lock. The
reason is that a deadlock between the remote render thread in
eglSwapBuffers and MediaCodecVideoEncoder eglCreateContext was observed.

The function calls that are now synchronized on EglBase.lock are:
eglCreateContext, eglMakeCurrent, eglSwapBuffers, and
SurfaceTexture.updateTexImage.

BUG=webrtc:5702

Review-Url: https://codereview.webrtc.org/1937933002
Cr-Commit-Position: refs/heads/master@{#12603}
This commit is contained in:
magjed
2016-05-03 01:24:39 -07:00
committed by Commit bot
parent 30f118effd
commit ddf165393f
2 changed files with 8 additions and 4 deletions

View File

@ -289,8 +289,10 @@ final class EglBase10 extends EglBase {
int[] contextAttributes = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
EGLContext rootContext =
sharedContext == null ? EGL10.EGL_NO_CONTEXT : sharedContext.eglContext;
EGLContext eglContext =
egl.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes);
final EGLContext eglContext;
synchronized (EglBase.lock) {
eglContext = egl.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes);
}
if (eglContext == EGL10.EGL_NO_CONTEXT) {
throw new RuntimeException("Failed to create EGL context");
}

View File

@ -246,8 +246,10 @@ public final class EglBase14 extends EglBase {
int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
EGLContext rootContext =
sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Context;
EGLContext eglContext =
EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
final EGLContext eglContext;
synchronized (EglBase.lock) {
eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
}
if (eglContext == EGL14.EGL_NO_CONTEXT) {
throw new RuntimeException("Failed to create EGL context");
}