fix(android): Fix app freeze on app/host pause on Android. Fix is quite simple, recording has to be stopped before the camera preview. (#2467)

Fix taken from: https://stackoverflow.com/questions/8914454/mediarecorder-stop-hanging-with-android-4-0-ics/18876200

TODO: Review Camera2 implementation since it might have the same issue.
This commit is contained in:
cristianoccazinsp 2019-09-05 17:59:58 -03:00 committed by Sibelius Seraphini
parent 654f1b221f
commit 57bf513d5b

View File

@ -159,10 +159,7 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
@Override
void stop() {
if (mCamera != null) {
mCamera.stopPreview();
mCamera.setPreviewCallback(null);
}
mShowingPreview = false;
if (mMediaRecorder != null) {
mMediaRecorder.stop();
@ -175,6 +172,12 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
mIsRecording = false;
}
}
if (mCamera != null) {
mCamera.stopPreview();
mCamera.setPreviewCallback(null);
}
releaseCamera();
}
@ -1003,7 +1006,7 @@ class Camera1 extends CameraViewImpl implements MediaRecorder.OnInfoListener,
if (minExposure != maxExposure) {
int scaledValue = 0;
if (mExposure >= 0 && mExposure <= 1) {
scaledValue = (int) (mExposure * (maxExposure - minExposure)) + minExposure;
scaledValue = (int) (mExposure * (maxExposure - minExposure)) + minExposure;
}
mCameraParameters.setExposureCompensation(scaledValue);