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

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

Issue 1988043002: Call java SurfaceTextureHelper.dispose from the corresponding C++ destructor. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Indentation tweak. 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
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 ef43c5e4dc97fbf16310de3f1ad5f1c19c41e91c..5677209a980d790ffb4b53d2f4d3c2f6cf1cc2a5 100644
--- a/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java
+++ b/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java
@@ -63,7 +63,7 @@ class SurfaceTextureHelper {
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.1.1_r1/android/graphics/SurfaceTexture.java#195.
// Therefore, in order to control the callback thread on API lvl < 21, the SurfaceTextureHelper
// is constructed on the |handler| thread.
- return ThreadUtils.invokeUninterruptibly(handler, new Callable<SurfaceTextureHelper>() {
+ return ThreadUtils.invokeAtFrontUninterruptibly(handler, new Callable<SurfaceTextureHelper>() {
@Override
public SurfaceTextureHelper call() {
try {
@@ -373,17 +373,18 @@ class SurfaceTextureHelper {
/**
* Stop listening. The listener set in startListening() is guaranteded to not receive any more
- * onTextureFrameAvailable() callbacks after this function returns. This function must be called
- * on the getHandler() thread.
+ * onTextureFrameAvailable() callbacks after this function returns.
*/
public void stopListening() {
- if (handler.getLooper().getThread() != Thread.currentThread()) {
- throw new IllegalStateException("Wrong thread.");
- }
Logging.d(TAG, "stopListening()");
handler.removeCallbacks(setListenerRunnable);
- this.listener = null;
- this.pendingListener = null;
+ ThreadUtils.invokeAtFrontUninterruptibly(handler, new Runnable() {
+ @Override
+ public void run() {
+ listener = null;
+ pendingListener = null;
+ }
+ });
}
/**
@@ -431,24 +432,15 @@ class SurfaceTextureHelper {
*/
public void dispose() {
Logging.d(TAG, "dispose()");
- if (handler.getLooper().getThread() == Thread.currentThread()) {
- isQuitting = true;
- if (!isTextureInUse) {
- release();
- }
- return;
- }
- final CountDownLatch barrier = new CountDownLatch(1);
- handler.postAtFrontOfQueue(new Runnable() {
- @Override public void run() {
+ ThreadUtils.invokeAtFrontUninterruptibly(handler, new Runnable() {
+ @Override
+ public void run() {
isQuitting = true;
- barrier.countDown();
if (!isTextureInUse) {
release();
}
}
});
- ThreadUtils.awaitUninterruptibly(barrier);
}
public void textureToYUV(ByteBuffer buf,
« no previous file with comments | « webrtc/api/androidtests/src/org/webrtc/SurfaceTextureHelperTest.java ('k') | webrtc/api/java/jni/androidvideocapturer_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698