Index: webrtc/api/java/android/org/webrtc/EglBase14.java |
diff --git a/webrtc/api/java/android/org/webrtc/EglBase14.java b/webrtc/api/java/android/org/webrtc/EglBase14.java |
index 5b377e0bad1a073800f7f2c9dc25d304004868a9..6ac61d062ca9baa36599197cb7d0d520cff8756c 100644 |
--- a/webrtc/api/java/android/org/webrtc/EglBase14.java |
+++ b/webrtc/api/java/android/org/webrtc/EglBase14.java |
@@ -168,17 +168,21 @@ public final class EglBase14 extends EglBase { |
if (eglSurface == EGL14.EGL_NO_SURFACE) { |
throw new RuntimeException("No EGLSurface - can't make current"); |
} |
- if (!EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) { |
- throw new RuntimeException("eglMakeCurrent failed"); |
+ synchronized (EglBase.lock) { |
+ if (!EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) { |
+ throw new RuntimeException("eglMakeCurrent failed"); |
+ } |
} |
} |
// Detach the current EGL context, so that it can be made current on another thread. |
@Override |
public void detachCurrent() { |
- if (!EGL14.eglMakeCurrent( |
- eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT)) { |
- throw new RuntimeException("eglMakeCurrent failed"); |
+ synchronized (EglBase.lock) { |
+ if (!EGL14.eglMakeCurrent( |
+ eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT)) { |
+ throw new RuntimeException("eglDetachCurrent failed"); |
+ } |
} |
} |
@@ -188,7 +192,9 @@ public final class EglBase14 extends EglBase { |
if (eglSurface == EGL14.EGL_NO_SURFACE) { |
throw new RuntimeException("No EGLSurface - can't swap buffers"); |
} |
- EGL14.eglSwapBuffers(eglDisplay, eglSurface); |
+ synchronized (EglBase.lock) { |
+ EGL14.eglSwapBuffers(eglDisplay, eglSurface); |
+ } |
} |
public void swapBuffers(long timeStampNs) { |
@@ -196,9 +202,11 @@ public final class EglBase14 extends EglBase { |
if (eglSurface == EGL14.EGL_NO_SURFACE) { |
throw new RuntimeException("No EGLSurface - can't swap buffers"); |
} |
- // See https://android.googlesource.com/platform/frameworks/native/+/tools_r22.2/opengl/specs/EGL_ANDROID_presentation_time.txt |
- EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, timeStampNs); |
- EGL14.eglSwapBuffers(eglDisplay, eglSurface); |
+ synchronized (EglBase.lock) { |
+ // See https://android.googlesource.com/platform/frameworks/native/+/tools_r22.2/opengl/specs/EGL_ANDROID_presentation_time.txt |
+ EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, timeStampNs); |
+ EGL14.eglSwapBuffers(eglDisplay, eglSurface); |
+ } |
} |
// Return an EGLDisplay, or die trying. |