Skip to content

Commit

Permalink
Buffer parameters to be used after unlocking, fixed preview size crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen Mols committed Dec 12, 2015
1 parent ef82369 commit ef7b3ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,6 @@ public void setPreviewSize() throws Exception {

wrapper.configureForPreview(800, 600);

verify(mockCamera.getNativeCameraParameters(), times(1)).setPreviewSize(700, 300);
}

@Test
public void setPreviewSizeDisplay90() throws Exception {
NativeCamera mockCamera = createCameraWithMockParameters(0, 0, 300, 700);
final CameraWrapper wrapper = new CameraWrapper(mockCamera, Surface.ROTATION_90);

wrapper.configureForPreview(800, 600);

verify(mockCamera.getNativeCameraParameters(), times(1)).setPreviewSize(300, 700);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ public void configureForPreview(int viewWidth, int viewHeight) {
final Parameters params = mNativeCamera.getNativeCameraParameters();
final CameraSize previewSize = getOptimalSize(params.getSupportedPreviewSizes(), viewWidth, viewHeight);

if (getRotationCorrection() % 180 == 0) {
params.setPreviewSize(previewSize.getHeight(), previewSize.getWidth());
} else {
params.setPreviewSize(previewSize.getWidth(), previewSize.getHeight());
}
params.setPreviewSize(previewSize.getWidth(), previewSize.getHeight());
params.setPreviewFormat(ImageFormat.NV21);
mNativeCamera.updateNativeCameraParameters(params);
mNativeCamera.setDisplayOrientation(getRotationCorrection());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
public class
NativeCamera {

private Camera camera = null;
private Camera camera = null;
private Parameters params = null;

public Camera getNativeCamera() {
return camera;
Expand Down Expand Up @@ -51,10 +52,14 @@ public void clearNativePreviewCallback() {
}

public Parameters getNativeCameraParameters() {
return camera.getParameters();
if (params == null) {
params = camera.getParameters();
}
return params;
}

public void updateNativeCameraParameters(Parameters params) {
this.params = params;
camera.setParameters(params);
}

Expand Down

0 comments on commit ef7b3ff

Please sign in to comment.