Make releaseEglSurface in EglRenderer asynchronous.
BUG=webrtc:6470 Review-Url: https://codereview.webrtc.org/2483143002 Cr-Commit-Position: refs/heads/master@{#14993}
This commit is contained in:
@ -435,8 +435,7 @@ public class EglRenderer implements VideoRenderer.Callbacks {
|
||||
/**
|
||||
* Release EGL surface. This function will block until the EGL surface is released.
|
||||
*/
|
||||
public void releaseEglSurface() {
|
||||
final CountDownLatch completionLatch = new CountDownLatch(1);
|
||||
public void releaseEglSurface(final Runnable completionCallback) {
|
||||
// Ensure that the render thread is no longer touching the Surface before returning from this
|
||||
// function.
|
||||
eglSurfaceCreationRunnable.setSurface(null /* surface */);
|
||||
@ -450,14 +449,13 @@ public class EglRenderer implements VideoRenderer.Callbacks {
|
||||
eglBase.detachCurrent();
|
||||
eglBase.releaseSurface();
|
||||
}
|
||||
completionLatch.countDown();
|
||||
completionCallback.run();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
completionLatch.countDown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
ThreadUtils.awaitUninterruptibly(completionLatch);
|
||||
completionCallback.run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -16,6 +16,7 @@ import android.graphics.Point;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/**
|
||||
* Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream on a SurfaceView.
|
||||
@ -159,7 +160,14 @@ public class SurfaceViewRenderer
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
ThreadUtils.checkIsOnMainThread();
|
||||
eglRenderer.releaseEglSurface();
|
||||
final CountDownLatch completionLatch = new CountDownLatch(1);
|
||||
eglRenderer.releaseEglSurface(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
completionLatch.countDown();
|
||||
}
|
||||
});
|
||||
ThreadUtils.awaitUninterruptibly(completionLatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user