| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 private void tryDeliverTextureFrame() { | 443 private void tryDeliverTextureFrame() { |
| 444 if (handler.getLooper().getThread() != Thread.currentThread()) { | 444 if (handler.getLooper().getThread() != Thread.currentThread()) { |
| 445 throw new IllegalStateException("Wrong thread."); | 445 throw new IllegalStateException("Wrong thread."); |
| 446 } | 446 } |
| 447 if (isQuitting || !hasPendingTexture || isTextureInUse || listener == null)
{ | 447 if (isQuitting || !hasPendingTexture || isTextureInUse || listener == null)
{ |
| 448 return; | 448 return; |
| 449 } | 449 } |
| 450 isTextureInUse = true; | 450 isTextureInUse = true; |
| 451 hasPendingTexture = false; | 451 hasPendingTexture = false; |
| 452 | 452 |
| 453 eglBase.makeCurrent(); | 453 // SurfaceTexture.updateTexImage apparently can compete and deadlock with eg
lSwapBuffers, |
| 454 surfaceTexture.updateTexImage(); | 454 // as observed on Nexus 5. Therefore, synchronize it with the EGL functions. |
| 455 // See https://bugs.chromium.org/p/webrtc/issues/detail?id=5702 for more inf
o. |
| 456 synchronized (EglBase.lock) { |
| 457 surfaceTexture.updateTexImage(); |
| 458 } |
| 455 | 459 |
| 456 final float[] transformMatrix = new float[16]; | 460 final float[] transformMatrix = new float[16]; |
| 457 surfaceTexture.getTransformMatrix(transformMatrix); | 461 surfaceTexture.getTransformMatrix(transformMatrix); |
| 458 final long timestampNs = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_C
REAM_SANDWICH) | 462 final long timestampNs = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_C
REAM_SANDWICH) |
| 459 ? surfaceTexture.getTimestamp() | 463 ? surfaceTexture.getTimestamp() |
| 460 : TimeUnit.MILLISECONDS.toNanos(SystemClock.elapsedRealtime()); | 464 : TimeUnit.MILLISECONDS.toNanos(SystemClock.elapsedRealtime()); |
| 461 listener.onTextureFrameAvailable(oesTextureId, transformMatrix, timestampNs)
; | 465 listener.onTextureFrameAvailable(oesTextureId, transformMatrix, timestampNs)
; |
| 462 } | 466 } |
| 463 | 467 |
| 464 private void release() { | 468 private void release() { |
| 465 if (handler.getLooper().getThread() != Thread.currentThread()) { | 469 if (handler.getLooper().getThread() != Thread.currentThread()) { |
| 466 throw new IllegalStateException("Wrong thread."); | 470 throw new IllegalStateException("Wrong thread."); |
| 467 } | 471 } |
| 468 if (isTextureInUse || !isQuitting) { | 472 if (isTextureInUse || !isQuitting) { |
| 469 throw new IllegalStateException("Unexpected release."); | 473 throw new IllegalStateException("Unexpected release."); |
| 470 } | 474 } |
| 471 synchronized (this) { | 475 synchronized (this) { |
| 472 if (yuvConverter != null) | 476 if (yuvConverter != null) |
| 473 yuvConverter.release(); | 477 yuvConverter.release(); |
| 474 } | 478 } |
| 475 eglBase.makeCurrent(); | |
| 476 GLES20.glDeleteTextures(1, new int[] {oesTextureId}, 0); | 479 GLES20.glDeleteTextures(1, new int[] {oesTextureId}, 0); |
| 477 surfaceTexture.release(); | 480 surfaceTexture.release(); |
| 478 eglBase.release(); | 481 eglBase.release(); |
| 479 handler.getLooper().quit(); | 482 handler.getLooper().quit(); |
| 480 } | 483 } |
| 481 } | 484 } |
| OLD | NEW |