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

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

Issue 2002963002: Android: Drop old frame in SurfaceTextureHelper.startListening() (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java
diff --git a/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java b/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java
index 09f78a58f4c23b583dcee1f1b34dc8a907a06566..ef43c5e4dc97fbf16310de3f1ad5f1c19c41e91c 100644
--- a/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java
+++ b/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java
@@ -309,8 +309,12 @@ class SurfaceTextureHelper {
Logging.d(TAG, "Setting listener to " + pendingListener);
listener = pendingListener;
pendingListener = null;
- // May alredy have a pending frame - try delivering it.
- tryDeliverTextureFrame();
+ // May have a pending frame from the previous capture session - drop it.
+ if (hasPendingTexture) {
+ // Calling updateTexImage() is neccessary in order to receive new frames.
+ updateTexImage();
+ hasPendingTexture = false;
+ }
}
};
@@ -455,6 +459,15 @@ class SurfaceTextureHelper {
getYuvConverter().convert(buf, width, height, stride, textureId, transformMatrix);
}
+ private void updateTexImage() {
+ // SurfaceTexture.updateTexImage apparently can compete and deadlock with eglSwapBuffers,
+ // as observed on Nexus 5. Therefore, synchronize it with the EGL functions.
+ // See https://bugs.chromium.org/p/webrtc/issues/detail?id=5702 for more info.
+ synchronized (EglBase.lock) {
+ surfaceTexture.updateTexImage();
+ }
+ }
+
private void tryDeliverTextureFrame() {
if (handler.getLooper().getThread() != Thread.currentThread()) {
throw new IllegalStateException("Wrong thread.");
@@ -465,12 +478,7 @@ class SurfaceTextureHelper {
isTextureInUse = true;
hasPendingTexture = false;
- // SurfaceTexture.updateTexImage apparently can compete and deadlock with eglSwapBuffers,
- // as observed on Nexus 5. Therefore, synchronize it with the EGL functions.
- // See https://bugs.chromium.org/p/webrtc/issues/detail?id=5702 for more info.
- synchronized (EglBase.lock) {
- surfaceTexture.updateTexImage();
- }
+ updateTexImage();
final float[] transformMatrix = new float[16];
surfaceTexture.getTransformMatrix(transformMatrix);
« no previous file with comments | « no previous file | webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698