I'm using the following code to release camera in onPause. But the line mCamera.release() takes 30 seconds on average to release the camera in Nexus 10 device. I've added logging before and after mCamera.release() and found that the time difference between printing these logs is 30 seconds.
private void releaseCamera() {
if (mCamera != null) {
previewing = false;
mCamera.setPreviewCallback(null);
if(mPreview != null)
mPreview.getHolder().removeCallback(mPreview);
Log.e("QR","Starting to call mCamera.release()");
mCamera.release();
Log.e("QR","Released Camera");
mCamera = null;
}
}
I'm calling mCamera.stopPreview() before calling releaseCamera()
Is there any way by which I can do it asynchrounously? Because it takes just less than a minute to go from the Camerapreview activity to the next activity.
Edit1: We reduced the preview size from the highest(1080x1920) to a middle range (480x800) and everything started working fine. Is the preview size has anything to do with the camera release in HAL?
mCamera.stopPreview()
? – InfecundmCamera.stopPreview()
before calling releaseCamera(). – Crosson