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.
|
* Release EGL surface. This function will block until the EGL surface is released.
|
||||||
*/
|
*/
|
||||||
public void releaseEglSurface() {
|
public void releaseEglSurface(final Runnable completionCallback) {
|
||||||
final CountDownLatch completionLatch = new CountDownLatch(1);
|
|
||||||
// Ensure that the render thread is no longer touching the Surface before returning from this
|
// Ensure that the render thread is no longer touching the Surface before returning from this
|
||||||
// function.
|
// function.
|
||||||
eglSurfaceCreationRunnable.setSurface(null /* surface */);
|
eglSurfaceCreationRunnable.setSurface(null /* surface */);
|
||||||
@ -450,14 +449,13 @@ public class EglRenderer implements VideoRenderer.Callbacks {
|
|||||||
eglBase.detachCurrent();
|
eglBase.detachCurrent();
|
||||||
eglBase.releaseSurface();
|
eglBase.releaseSurface();
|
||||||
}
|
}
|
||||||
completionLatch.countDown();
|
completionCallback.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
return;
|
||||||
completionLatch.countDown();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ThreadUtils.awaitUninterruptibly(completionLatch);
|
completionCallback.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import android.graphics.Point;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream on a SurfaceView.
|
* Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream on a SurfaceView.
|
||||||
@ -159,7 +160,14 @@ public class SurfaceViewRenderer
|
|||||||
@Override
|
@Override
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
ThreadUtils.checkIsOnMainThread();
|
ThreadUtils.checkIsOnMainThread();
|
||||||
eglRenderer.releaseEglSurface();
|
final CountDownLatch completionLatch = new CountDownLatch(1);
|
||||||
|
eglRenderer.releaseEglSurface(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
completionLatch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ThreadUtils.awaitUninterruptibly(completionLatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user