From c646b21629ac4c386c076ce226531cdb8618c7c4 Mon Sep 17 00:00:00 2001 From: Gian-Carlo Pascutto Date: Wed, 5 Jun 2013 08:26:00 +0200 Subject: [PATCH] Bug 874546 - Detach the preview when the Camera surface is destroyed. r=blassey --- .../webrtc/videoengine/VideoCaptureAndroid.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java index b9f5216a49f..20226c20c80 100644 --- a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java +++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java @@ -214,8 +214,7 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { return res; } - public int StopCapture() { - Log.d(TAG, "StopCapture"); + public int DetachCamera() { try { previewBufferLock.lock(); isCaptureRunning = false; @@ -224,14 +223,18 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { camera.setPreviewCallbackWithBuffer(null); } catch (Exception ex) { - Log.e(TAG, "Failed to stop camera"); + Log.e(TAG, "Failed to stop camera: " + ex.getMessage()); return -1; } - - isCaptureStarted = false; return 0; } + public int StopCapture() { + Log.d(TAG, "StopCapture"); + isCaptureStarted = false; + return DetachCamera(); + } + native void ProvideCameraFrame(byte[] data, int length, long captureObject); public void onPreviewFrame(byte[] data, Camera camera) { @@ -314,5 +317,6 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback { public void surfaceDestroyed(SurfaceHolder holder) { Log.d(TAG, "VideoCaptureAndroid::surfaceDestroyed"); isSurfaceReady = false; + DetachCamera(); } }