fix(record): android crash fix (#2697)

Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>
This commit is contained in:
cristianoccazinsp 2020-02-05 12:46:02 -03:00 committed by GitHub
parent 9b4af8e649
commit 7c2572dc7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1414,26 +1414,33 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
private void stopMediaRecorder() {
if (mMediaRecorder != null) {
try {
mMediaRecorder.stop();
} catch (RuntimeException ex) {
Log.e("CAMERA_1::", "stopMediaRecorder failed", ex);
synchronized(this){
if (mMediaRecorder != null) {
try {
mMediaRecorder.stop();
} catch (RuntimeException ex) {
Log.e("CAMERA_1::", "stopMediaRecorder stop failed", ex);
}
try{
mMediaRecorder.reset();
mMediaRecorder.release();
} catch (RuntimeException ex) {
Log.e("CAMERA_1::", "stopMediaRecorder reset failed", ex);
}
mMediaRecorder = null;
}
mMediaRecorder.reset();
mMediaRecorder.release();
mMediaRecorder = null;
int deviceOrientation = displayOrientationToOrientationEnum(mDeviceOrientation);
if (mVideoPath == null || !new File(mVideoPath).exists()) {
mCallback.onVideoRecorded(null, mOrientation != Constants.ORIENTATION_AUTO ? mOrientation : deviceOrientation, deviceOrientation);
return;
}
mCallback.onVideoRecorded(mVideoPath, mOrientation != Constants.ORIENTATION_AUTO ? mOrientation : deviceOrientation, deviceOrientation);
mVideoPath = null;
}
int deviceOrientation = displayOrientationToOrientationEnum(mDeviceOrientation);
if (mVideoPath == null || !new File(mVideoPath).exists()) {
mCallback.onVideoRecorded(null, mOrientation != Constants.ORIENTATION_AUTO ? mOrientation : deviceOrientation, deviceOrientation);
return;
}
mCallback.onVideoRecorded(mVideoPath, mOrientation != Constants.ORIENTATION_AUTO ? mOrientation : deviceOrientation, deviceOrientation);
mVideoPath = null;
}
private void setCamcorderProfile(CamcorderProfile profile, boolean recordAudio) {