pull/517/head
Mattia Iavarone 5 years ago committed by GitHub
parent 86b18c5832
commit f2350512f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      cameraview/src/main/java/com/otaliastudios/cameraview/video/SnapshotVideoRecorder.java
  2. 2
      cameraview/src/main/java/com/otaliastudios/cameraview/video/encoding/AudioMediaEncoder.java
  3. 2
      demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java

@ -183,26 +183,17 @@ public class SnapshotVideoRecorder extends VideoRecorder implements RendererFram
} }
if (mEncoderEngine != null) { if (mEncoderEngine != null) {
// can happen on teardown // Can happen on teardown. At least it used to.
// NOTE: If this still happens, I would say we can still crash on mOverlaySurface
// calls above. We might have to add some synchronization.
mEncoderEngine.notify(TextureMediaEncoder.FRAME_EVENT, frame); mEncoderEngine.notify(TextureMediaEncoder.FRAME_EVENT, frame);
} }
} }
if (mCurrentState == STATE_RECORDING && mDesiredState == STATE_NOT_RECORDING) { if (mCurrentState == STATE_RECORDING && mDesiredState == STATE_NOT_RECORDING) {
LOG.i("Stopping the encoder engine."); LOG.i("Stopping the encoder engine.");
mCurrentState = STATE_NOT_RECORDING; // before nulling encoderEngine! mCurrentState = STATE_NOT_RECORDING;
mEncoderEngine.stop(); mEncoderEngine.stop();
mEncoderEngine = null;
mPreview.removeRendererFrameCallback(SnapshotVideoRecorder.this);
mPreview = null;
if (mOverlaySurfaceTexture != null) {
mOverlaySurfaceTexture.release();
mOverlaySurfaceTexture = null;
}
if (mOverlaySurface != null) {
mOverlaySurface.release();
mOverlaySurface = null;
}
} }
} }
@ -241,6 +232,15 @@ public class SnapshotVideoRecorder extends VideoRecorder implements RendererFram
mCurrentState = STATE_NOT_RECORDING; mCurrentState = STATE_NOT_RECORDING;
mDesiredState = STATE_NOT_RECORDING; mDesiredState = STATE_NOT_RECORDING;
mPreview.removeRendererFrameCallback(SnapshotVideoRecorder.this); mPreview.removeRendererFrameCallback(SnapshotVideoRecorder.this);
mPreview = null;
if (mOverlaySurfaceTexture != null) {
mOverlaySurfaceTexture.release();
mOverlaySurfaceTexture = null;
}
if (mOverlaySurface != null) {
mOverlaySurface.release();
mOverlaySurface = null;
}
mEncoderEngine = null; mEncoderEngine = null;
dispatchResult(); dispatchResult();
} }

@ -28,7 +28,7 @@ public class AudioMediaEncoder extends MediaEncoder {
private static final String TAG = AudioMediaEncoder.class.getSimpleName(); private static final String TAG = AudioMediaEncoder.class.getSimpleName();
private static final CameraLogger LOG = CameraLogger.create(TAG); private static final CameraLogger LOG = CameraLogger.create(TAG);
private static final boolean PERFORMANCE_DEBUG = true; private static final boolean PERFORMANCE_DEBUG = false;
private static final boolean PERFORMANCE_FILL_GAPS = true; private static final boolean PERFORMANCE_FILL_GAPS = true;
private boolean mRequestStop = false; private boolean mRequestStop = false;

@ -44,7 +44,7 @@ import java.util.List;
public class CameraActivity extends AppCompatActivity implements View.OnClickListener, OptionView.Callback { public class CameraActivity extends AppCompatActivity implements View.OnClickListener, OptionView.Callback {
private final static CameraLogger LOG = CameraLogger.create("DemoApp"); private final static CameraLogger LOG = CameraLogger.create("DemoApp");
private final static boolean USE_FRAME_PROCESSOR = true; private final static boolean USE_FRAME_PROCESSOR = false;
private final static boolean DECODE_BITMAP = true; private final static boolean DECODE_BITMAP = true;
private CameraView camera; private CameraView camera;

Loading…
Cancel
Save