Android SurfaceViewRenderer: Make sure not to call eglCreateSurface() twice

eglCreateSurface() calls are posted to the render thread from both init() and surfaceCreated(). If the render thread does not process the eglCreateSurface() message from init() before surfaceCreated() is called, eglCreateSurface() will be called twice resulting in a crash.

This CL makes sure eglCreateSurface() is only called once.

BUG=b/25815604
R=hbos@webrtc.org

Review URL: https://codereview.webrtc.org/1466133002 .

Cr-Commit-Position: refs/heads/master@{#10769}
This commit is contained in:
Magnus Jedvert 2015-11-24 13:54:31 +01:00
parent 97c821dc56
commit 4f2152e328

View File

@ -173,7 +173,7 @@ public class SurfaceViewRenderer extends SurfaceView
runOnRenderThread(new Runnable() {
@Override public void run() {
synchronized (layoutLock) {
if (isSurfaceCreated) {
if (isSurfaceCreated && !eglBase.hasSurface()) {
eglBase.createSurface(getHolder().getSurface());
eglBase.makeCurrent();
// Necessary for YUV frames with odd width.