Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: webrtc/api/java/android/org/webrtc/EglBase14.java

Issue 1848483002: Android EGL: Synchronize calls to eglSwapBuffers and eglMakeCurrent (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Address comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.
« no previous file with comments | « webrtc/api/java/android/org/webrtc/EglBase10.java ('k') | webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698