Fix AppRTCDemo crash when room is connected after PC is destroyed.

Also move VideoRendererGui.dispose() to the section with public API.

BUG=4909
R=wzh@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#9792}
This commit is contained in:
Alex Glaznev
2015-08-26 16:02:21 -07:00
parent 13d35f6ffc
commit c47a01d647
2 changed files with 25 additions and 20 deletions

View File

@ -89,25 +89,6 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
yuvImageRenderers = new ArrayList<YuvImageRenderer>();
}
public static synchronized void dispose() {
if (instance == null){
return;
}
synchronized (instance.yuvImageRenderers) {
for (YuvImageRenderer yuvImageRenderer : instance.yuvImageRenderers) {
yuvImageRenderer.release();
}
instance.yuvImageRenderers.clear();
if (instance.drawer != null) {
instance.drawer.release();
}
}
instance.surface = null;
instance.eglContext = null;
instance.eglContextReady = null;
instance = null;
}
/**
* Class used to display stream of YUV420 frames at particular location
* on a screen. New video frames are sent to display using renderFrame()
@ -468,6 +449,27 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
return eglContext;
}
/** Releases GLSurfaceView video renderer. */
public static synchronized void dispose() {
if (instance == null){
return;
}
Log.d(TAG, "VideoRendererGui.dispose");
synchronized (instance.yuvImageRenderers) {
for (YuvImageRenderer yuvImageRenderer : instance.yuvImageRenderers) {
yuvImageRenderer.release();
}
instance.yuvImageRenderers.clear();
if (instance.drawer != null) {
instance.drawer.release();
}
}
instance.surface = null;
eglContext = null;
eglContextReady = null;
instance = null;
}
/**
* Creates VideoRenderer with top left corner at (x, y) and resolution
* (width, height). All parameters are in percentage of screen resolution.

View File

@ -369,7 +369,10 @@ public class CallActivity extends Activity
private void callConnected() {
final long delta = System.currentTimeMillis() - callStartedTimeMs;
Log.i(TAG, "Call connected: delay=" + delta + "ms");
if (peerConnectionClient == null || isError) {
Log.w(TAG, "Call is connected in closed or error state");
return;
}
// Update video view.
updateVideoView();
// Enable statistics callback.