Skip to content

Commit

Permalink
[run instrumentation] Fix stopVideoPostPrepare
Browse files Browse the repository at this point in the history
  • Loading branch information
azaat committed Mar 23, 2021
1 parent 22d6f66 commit 50ca36a
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions app/src/main/java/net/sourceforge/opencamera/preview/Preview.java
Original file line number Diff line number Diff line change
Expand Up @@ -965,34 +965,6 @@ private void configureTransform() {
private void stopVideoPostPrepare(boolean from_restart) {
Log.d(TAG, "Stopping video post prepare");


if( MyDebug.LOG )
Log.d(TAG, "stopVideo()");

applicationInterface.cameraInOperation(false, true);
reconnectCamera(false); // n.b., if something went wrong with video, then we reopen the camera - which may fail (or simply not reopen, e.g., if app is now paused)


if( video_recorder == null ) {
// no need to do anything if not recording
// (important to exit, otherwise we'll momentarily switch the take photo icon to video mode in MyApplicationInterface.stoppingVideo() when opening the settings in landscape mode
if( MyDebug.LOG )
Log.d(TAG, "video wasn't recording anyway");
return;
}
if( flashVideoTimerTask != null ) {
flashVideoTimerTask.cancel();
flashVideoTimerTask = null;
}
if( batteryCheckVideoTimerTask != null ) {
batteryCheckVideoTimerTask.cancel();
batteryCheckVideoTimerTask = null;
}
if( !from_restart ) {
remaining_restart_video = 0;
}


if( video_recorder != null ) { // check again, just to be safe
if( MyDebug.LOG )
Log.d(TAG, "stop video recording");
Expand Down Expand Up @@ -1033,6 +1005,32 @@ private void stopVideoPostPrepare(boolean from_restart) {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void stopVideo(boolean from_restart) {
applicationInterface.stoppingVideo();
if( MyDebug.LOG )
Log.d(TAG, "stopVideo()");

applicationInterface.cameraInOperation(false, true);
reconnectCamera(false); // n.b., if something went wrong with video, then we reopen the camera - which may fail (or simply not reopen, e.g., if app is now paused)


if( video_recorder == null ) {
// no need to do anything if not recording
// (important to exit, otherwise we'll momentarily switch the take photo icon to video mode in MyApplicationInterface.stoppingVideo() when opening the settings in landscape mode
if( MyDebug.LOG )
Log.d(TAG, "video wasn't recording anyway");
return;
}
if( flashVideoTimerTask != null ) {
flashVideoTimerTask.cancel();
flashVideoTimerTask = null;
}
if( batteryCheckVideoTimerTask != null ) {
batteryCheckVideoTimerTask.cancel();
batteryCheckVideoTimerTask = null;
}
if( !from_restart ) {
remaining_restart_video = 0;
}


camera_controller.closeVideoRecordingSession();

Expand Down

0 comments on commit 50ca36a

Please sign in to comment.