Fix VideoRecorder bug

pull/360/head
Mattia Iavarone 7 years ago
parent 92b0b05c68
commit dbdade2525
  1. 3
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java
  2. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/MediaRecorderVideoRecorder.java
  3. 13
      cameraview/src/main/java/com/otaliastudios/cameraview/VideoRecorder.java

@ -205,7 +205,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
mFrameManager.release();
if (mCamera != null) {
LOG.i("onStop:", "Clean up.", "Ending video.");
LOG.i("onStop:", "Clean up.", "Ending video. mVideoRecorder is null?", mVideoRecorder == null);
if (mVideoRecorder != null) {
mVideoRecorder.stop();
mVideoRecorder = null;
@ -655,6 +655,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
@Override
public void run() {
mIsTakingVideo = false;
LOG.i("stopVideo", "mVideoRecorder is null?", mVideoRecorder == null);
if (mVideoRecorder != null) {
mVideoRecorder.stop();
mVideoRecorder = null;

@ -75,7 +75,7 @@ class MediaRecorderVideoRecorder extends VideoRecorder {
}
@Override
void stop() {
void close() {
if (mMediaRecorder != null) {
try {
mMediaRecorder.stop();
@ -85,8 +85,6 @@ class MediaRecorderVideoRecorder extends VideoRecorder {
}
mMediaRecorder.release();
}
super.stop();
mProfile = null;
mMediaRecorder = null;
}

@ -21,12 +21,17 @@ abstract class VideoRecorder {
abstract void start();
void stop() {
mListener.onVideoResult(mResult);
mListener = null;
mResult = null;
final void stop() {
if (mListener != null) {
close();
mListener.onVideoResult(mResult);
mListener = null;
mResult = null;
}
}
abstract void close();
interface VideoResultListener {
void onVideoResult(@Nullable VideoResult result);
}

Loading…
Cancel
Save