Restart Android capture after orientation change.

Also prevent an NPE on exit.

BUG=1537

Review URL: https://webrtc-codereview.appspot.com/1248004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3723 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
fischman@webrtc.org 2013-03-25 22:08:51 +00:00
parent c83a00ad49
commit 0e3077ab1f

View File

@ -215,6 +215,7 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
int width = 0;
int height = 0;
int framerate = 0;
boolean wasCaptureRunning = isCaptureRunning;
if (isCaptureRunning) {
width = mCaptureWidth;
@ -237,7 +238,7 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
}
camera.setDisplayOrientation(resultRotation);
if (isCaptureRunning) {
if (wasCaptureRunning) {
StartCapture(width, height, framerate);
}
previewBufferLock.unlock();
@ -264,7 +265,9 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
Log.d(TAG, "VideoCaptureAndroid::surfaceDestroyed");
captureLock.lock();
try {
camera.setPreviewDisplay(null);
if (camera != null) {
camera.setPreviewDisplay(null);
}
} catch (IOException e) {
Log.e(TAG, "Failed to clear preview surface!", e);
}