|
|
@ -66,7 +66,10 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Preview surface is now available. If camera is open, set up.
|
|
|
|
/** |
|
|
|
|
|
|
|
* Preview surface is now available. If camera is open, set up. |
|
|
|
|
|
|
|
* At this point we are sure that mPreview is not null. |
|
|
|
|
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSurfaceAvailable() { |
|
|
|
public void onSurfaceAvailable() { |
|
|
|
LOG.i("onSurfaceAvailable:", "Size is", mPreview.getOutputSurfaceSize()); |
|
|
|
LOG.i("onSurfaceAvailable:", "Size is", mPreview.getOutputSurfaceSize()); |
|
|
@ -80,8 +83,11 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Preview surface did change its size. Compute a new preview size.
|
|
|
|
/** |
|
|
|
// This requires stopping and restarting the preview.
|
|
|
|
* Preview surface did change its size. Compute a new preview size. |
|
|
|
|
|
|
|
* This requires stopping and restarting the preview. |
|
|
|
|
|
|
|
* At this point we are sure that mPreview is not null. |
|
|
|
|
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSurfaceChanged() { |
|
|
|
public void onSurfaceChanged() { |
|
|
|
LOG.i("onSurfaceChanged, size is", mPreview.getOutputSurfaceSize()); |
|
|
|
LOG.i("onSurfaceChanged, size is", mPreview.getOutputSurfaceSize()); |
|
|
@ -119,8 +125,11 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
return isCameraAvailable() && mPreview != null && mPreview.hasSurface() && !mIsBound; |
|
|
|
return isCameraAvailable() && mPreview != null && mPreview.hasSurface() && !mIsBound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// The act of binding an "open" camera to a "ready" preview.
|
|
|
|
/** |
|
|
|
// These can happen at different times but we want to end up here.
|
|
|
|
* The act of binding an "open" camera to a "ready" preview. |
|
|
|
|
|
|
|
* These can happen at different times but we want to end up here. |
|
|
|
|
|
|
|
* At this point we are sure that mPreview is not null. |
|
|
|
|
|
|
|
*/ |
|
|
|
@WorkerThread |
|
|
|
@WorkerThread |
|
|
|
private void bindToSurface() { |
|
|
|
private void bindToSurface() { |
|
|
|
LOG.i("bindToSurface:", "Started"); |
|
|
|
LOG.i("bindToSurface:", "Started"); |
|
|
@ -275,7 +284,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
if (mCamera != null) { |
|
|
|
if (mCamera != null) { |
|
|
|
stopPreview(); |
|
|
|
stopPreview(); |
|
|
|
unbindFromSurface(); |
|
|
|
if (mIsBound) unbindFromSurface(); |
|
|
|
destroyCamera(); |
|
|
|
destroyCamera(); |
|
|
|
} |
|
|
|
} |
|
|
|
mCameraOptions = null; |
|
|
|
mCameraOptions = null; |
|
|
@ -440,8 +449,12 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
Camera.CameraInfo info = new Camera.CameraInfo(); |
|
|
|
Camera.CameraInfo info = new Camera.CameraInfo(); |
|
|
|
Camera.getCameraInfo(mCameraId, info); |
|
|
|
Camera.getCameraInfo(mCameraId, info); |
|
|
|
if (info.canDisableShutterSound) { |
|
|
|
if (info.canDisableShutterSound) { |
|
|
|
mCamera.enableShutterSound(mPlaySounds); |
|
|
|
try { |
|
|
|
return true; |
|
|
|
// this method is documented to throw on some occasions. #377
|
|
|
|
|
|
|
|
return mCamera.enableShutterSound(mPlaySounds); |
|
|
|
|
|
|
|
} catch (RuntimeException exception) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (mPlaySounds) { |
|
|
|
if (mPlaySounds) { |
|
|
|