pull/696/head
Mattia Iavarone 6 years ago
parent 74121d99b4
commit c35f206d94
  1. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java
  2. 3
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java
  3. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/picture/Full1PictureRecorder.java
  4. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/video/FullVideoRecorder.java

@ -240,15 +240,19 @@ public class Camera1Engine extends CameraEngine implements
@NonNull @NonNull
@Override @Override
protected Task<Void> onStopPreview() { protected Task<Void> onStopPreview() {
LOG.i("onStopPreview:", "Started.");
if (mVideoRecorder != null) { if (mVideoRecorder != null) {
mVideoRecorder.stop(true); mVideoRecorder.stop(true);
mVideoRecorder = null; mVideoRecorder = null;
} }
mPictureRecorder = null; mPictureRecorder = null;
getFrameManager().release(); getFrameManager().release();
LOG.i("onStopPreview:", "Releasing preview buffers.");
mCamera.setPreviewCallbackWithBuffer(null); // Release anything left mCamera.setPreviewCallbackWithBuffer(null); // Release anything left
try { try {
LOG.i("onStopPreview:", "Stopping preview.");
mCamera.stopPreview(); mCamera.stopPreview();
LOG.i("onStopPreview:", "Stopped preview.");
} catch (Exception e) { } catch (Exception e) {
LOG.e("stopPreview", "Could not stop preview", e); LOG.e("stopPreview", "Could not stop preview", e);
} }

@ -627,7 +627,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv
@NonNull @NonNull
@Override @Override
protected Task<Void> onStopPreview() { protected Task<Void> onStopPreview() {
LOG.i("onStopPreview:", "About to clean up."); LOG.i("onStopPreview:", "Started.");
if (mVideoRecorder != null) { if (mVideoRecorder != null) {
// This should synchronously call onVideoResult that will reset the repeating builder // This should synchronously call onVideoResult that will reset the repeating builder
// to the PREVIEW template. This is very important. // to the PREVIEW template. This is very important.
@ -643,6 +643,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv
// are discarded as fast as possible, which is exactly what we want. // are discarded as fast as possible, which is exactly what we want.
// NOTE: this call is asynchronous. Should find a good way to wait for the outcome. // NOTE: this call is asynchronous. Should find a good way to wait for the outcome.
LOG.i("onStopPreview:", "calling abortCaptures()."); LOG.i("onStopPreview:", "calling abortCaptures().");
// TODO HANGS (rare, emulator only)
mSession.abortCaptures(); mSession.abortCaptures();
LOG.i("onStopPreview:", "called abortCaptures()."); LOG.i("onStopPreview:", "called abortCaptures().");
} catch (CameraAccessException e) { } catch (CameraAccessException e) {

@ -35,6 +35,7 @@ public class Full1PictureRecorder extends FullPictureRecorder {
@Override @Override
public void take() { public void take() {
LOG.i("take() called."); LOG.i("take() called.");
// TODO HANGS (rare, emulator only)
mCamera.takePicture( mCamera.takePicture(
new Camera.ShutterCallback() { new Camera.ShutterCallback() {
@Override @Override

@ -307,6 +307,7 @@ public abstract class FullVideoRecorder extends VideoRecorder {
dispatchVideoRecordingEnd(); dispatchVideoRecordingEnd();
try { try {
LOG.i("stop:", "Stopping MediaRecorder..."); LOG.i("stop:", "Stopping MediaRecorder...");
// TODO HANGS (rare, emulator only)
mMediaRecorder.stop(); mMediaRecorder.stop();
LOG.i("stop:", "Stopped MediaRecorder."); LOG.i("stop:", "Stopped MediaRecorder.");
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save