优化Camera初始化相关策略,减少出现卡顿的可能性(#64,#65)

This commit is contained in:
jenly1314
2019-12-16 11:35:57 +08:00
parent c7dbf12f57
commit 69fef8f69f
10 changed files with 82 additions and 73 deletions

View File

@@ -89,7 +89,7 @@ public final class CameraManager {
* @param holder The surface object which the camera will draw preview frames into.
* @throws IOException Indicates the camera driver failed to open.
*/
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
public void openDriver(SurfaceHolder holder) throws IOException {
OpenCamera theCamera = camera;
if (theCamera == null) {
theCamera = OpenCameraInterface.open(requestedCameraId);
@@ -146,7 +146,7 @@ public final class CameraManager {
/**
* Closes the camera driver if still in use.
*/
public synchronized void closeDriver() {
public void closeDriver() {
if (camera != null) {
camera.getCamera().release();
camera = null;
@@ -160,7 +160,7 @@ public final class CameraManager {
/**
* Asks the camera hardware to begin drawing preview frames to the screen.
*/
public synchronized void startPreview() {
public void startPreview() {
OpenCamera theCamera = camera;
if (theCamera != null && !previewing) {
theCamera.getCamera().startPreview();
@@ -172,7 +172,7 @@ public final class CameraManager {
/**
* Tells the camera to stop drawing preview frames.
*/
public synchronized void stopPreview() {
public void stopPreview() {
if (autoFocusManager != null) {
autoFocusManager.stop();
autoFocusManager = null;