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

Commit c6bc0001 authored by Mark Harman's avatar Mark Harman
Browse files

Localise RuntimeException around video_recorder.start().

parent 00b497a3
Loading
Loading
Loading
Loading
+33 −13
Original line number Diff line number Diff line
@@ -4283,7 +4283,7 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
	/** Start video recording.
	 */
	@TargetApi(Build.VERSION_CODES.LOLLIPOP)
	private void startVideoRecording(boolean max_filesize_restart) {
	private void startVideoRecording(final boolean max_filesize_restart) {
		focus_success = FOCUS_DONE; // clear focus rectangle (don't do for taking photos yet)
		// initialise just in case:
		boolean created_video_file = false;
@@ -4505,9 +4505,39 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
				camera_controller.initVideoRecorderPostPrepare(video_recorder);
				if( MyDebug.LOG )
					Log.d(TAG, "about to start video recorder");

				try {
					video_recorder.start();
					videoRecordingStarted(max_filesize_restart);
				}
				catch(RuntimeException e) {
					// needed for emulator at least - although MediaRecorder not meant to work with emulator, it's good to fail gracefully
					if( MyDebug.LOG )
						Log.e(TAG, "runtime exception starting video recorder");
					e.printStackTrace();
					// told_app_starting must be true if we're here
					applicationInterface.stoppingVideo();
					failedToStartVideoRecorder(profile);
				}

				/*new AsyncTask<Void, Void, Void>() {
					private static final String TAG = "video_recorder.start";

					@Override
					protected Void doInBackground(Void... voids) {
						if( MyDebug.LOG )
							Log.d(TAG, "doInBackground, async task: " + this);
						video_recorder.start();
						return null;
					}

					protected void onPostExecute(Void param) {
						if( MyDebug.LOG )
							Log.d(TAG, "onPostExecute, async task: " + this);
						videoRecordingStarted(max_filesize_restart);
					}
				}.execute();*/
			}
			catch(IOException e) {
				if( MyDebug.LOG )
					Log.e(TAG, "failed to save video");
@@ -4523,16 +4553,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
				applicationInterface.cameraInOperation(false, true);
				this.reconnectCamera(true);
			}
			catch(RuntimeException e) {
				// needed for emulator at least - although MediaRecorder not meant to work with emulator, it's good to fail gracefully
				if( MyDebug.LOG )
					Log.e(TAG, "runtime exception starting video recorder");
				e.printStackTrace();
				if( told_app_starting ) {
					applicationInterface.stoppingVideo();
				}
				failedToStartVideoRecorder(profile);
			}
			catch(CameraControllerException e) {
				if( MyDebug.LOG )
					Log.e(TAG, "camera exception starting video recorder");