Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00b497a3 authored by Mark Harman's avatar Mark Harman
Browse files

Move post start() code to videoRecordingStarted; some of this code should only...

Move post start() code to videoRecordingStarted; some of this code should only be done if we didn't throw an exception.
parent 0fcda616
Loading
Loading
Loading
Loading
+93 −91
Original line number Diff line number Diff line
@@ -4506,20 +4506,7 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
				if( MyDebug.LOG )
					Log.d(TAG, "about to start video recorder");
				video_recorder.start();
				video_recorder_is_paused = false;
				if( MyDebug.LOG )
					Log.d(TAG, "video recorder started");
				if( test_video_failure ) {
					if( MyDebug.LOG )
						Log.d(TAG, "test_video_failure is true");
					throw new RuntimeException();
				}
				video_start_time = System.currentTimeMillis();
				video_start_time_set = true;
				applicationInterface.startedVideo();
				// Don't send intent for ACTION_MEDIA_SCANNER_SCAN_FILE yet - wait until finished, so we get completed file.
				// Don't do any further calls after applicationInterface.startedVideo() that might throw an error - instead video error
				// should be handled by including a call to stopVideo() (since the video_recorder has started).
				videoRecordingStarted(max_filesize_restart);
			}
			catch(IOException e) {
				if( MyDebug.LOG )
@@ -4570,8 +4557,25 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
				this.reconnectCamera(true);
				this.showToast(null, R.string.video_no_free_space);
			}
		}
	}

	private void videoRecordingStarted(boolean max_filesize_restart) {
		if( MyDebug.LOG )
			Log.d(TAG, "video recorder started");
		video_recorder_is_paused = false;
		if( test_video_failure ) {
			if( MyDebug.LOG )
				Log.d(TAG, "test_video_failure is true");
			throw new RuntimeException();
		}
		video_start_time = System.currentTimeMillis();
		video_start_time_set = true;
		applicationInterface.startedVideo();
		// Don't send intent for ACTION_MEDIA_SCANNER_SCAN_FILE yet - wait until finished, so we get completed file.
		// Don't do any further calls after applicationInterface.startedVideo() that might throw an error - instead video error
		// should be handled by including a call to stopVideo() (since the video_recorder has started).

			{
		// handle restarts
		if( remaining_restart_video == 0 && !max_filesize_restart ) {
			remaining_restart_video = applicationInterface.getVideoRestartTimesPref();
@@ -4654,8 +4658,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
			batteryCheckVideoTimer.schedule(batteryCheckVideoTimerTask = new BatteryCheckVideoTimerTask(), battery_check_interval_ms, battery_check_interval_ms);
		}
	}
		}
	}
	
	private void failedToStartVideoRecorder(CamcorderProfile profile) {
		applicationInterface.onVideoRecordStartError(profile);