Not reset the Recorder state when ERROR_RECORDER_ERROR
If the recording is finalized with ERROR_RECORDER_ERROR, it can not be
recorvered without reinitializing the recorder, So keep the state at
ERROR so that the next recording will also be finalized immediately
after started.
Also correct the typo of State.RESETTING
Bug: b/194263267
Test: ./gradlew bOS
Change-Id: I11970201070bceb7aa596bcb2ae4859784a5141f
diff --git a/camera/camera-video/src/main/java/androidx/camera/video/Recorder.java b/camera/camera-video/src/main/java/androidx/camera/video/Recorder.java
index 29f4969..f0e2f2e 100644
--- a/camera/camera-video/src/main/java/androidx/camera/video/Recorder.java
+++ b/camera/camera-video/src/main/java/androidx/camera/video/Recorder.java
@@ -147,7 +147,7 @@
/**
* There's a running recording and the Recorder is being reset.
*/
- RESETING,
+ RESETTING,
/**
* The Recorder encountered errors and any operation will attempt will throw an
* {@link IllegalStateException}. Users can handle the error by monitoring
@@ -305,7 +305,7 @@
public void onSurfaceRequested(@NonNull SurfaceRequest request) {
synchronized (mLock) {
switch (getObservableData(mState)) {
- case RESETING:
+ case RESETTING:
// Fall-through
case PENDING_RECORDING:
// Fall-through
@@ -484,7 +484,7 @@
ActiveRecording activeRecording = ActiveRecording.from(pendingRecording);
mRunningRecording = activeRecording;
switch (getObservableData(mState)) {
- case RESETING:
+ case RESETTING:
// Fall-through
case INITIALIZING:
// The recording will automatically start once the initialization completes.
@@ -516,7 +516,7 @@
switch (getObservableData(mState)) {
case PENDING_RECORDING:
// Fall-through
- case RESETING:
+ case RESETTING:
// Fall-through
case INITIALIZING:
// The recording will automatically pause once the initialization completes.
@@ -545,7 +545,7 @@
switch (getObservableData(mState)) {
case PENDING_PAUSED:
// Fall-through
- case RESETING:
+ case RESETTING:
// Fall-through
case INITIALIZING:
// The recording will automatically start once the initialization completes.
@@ -576,7 +576,7 @@
// Fall-through
case PENDING_PAUSED:
// Fall-through
- case RESETING:
+ case RESETTING:
// Fall-through
case INITIALIZING:
finalizeRecording(VideoRecordEvent.ERROR_NO_VALID_DATA,
@@ -622,12 +622,12 @@
case PAUSED:
// Fall-through
case RECORDING:
- setState(State.RESETING);
+ setState(State.RESETTING);
// If there's an active recording, stop it first then release the resources
// at finalizeRecording().
mSequentialExecutor.execute(() -> stopInternal(VideoRecordEvent.ERROR_NONE));
break;
- case RESETING:
+ case RESETTING:
// No-Op, the Recorder is being reset.
break;
}
@@ -673,7 +673,7 @@
// Fall-through
case PAUSED:
// Fall-through
- case RESETING:
+ case RESETTING:
throw new IllegalStateException(
"Incorrectly invoke onInitialized() in state " + state);
case INITIALIZING:
@@ -1314,10 +1314,14 @@
setAudioState(AudioState.INITIALIZING);
}
synchronized (mLock) {
- if (getObservableData(mState) == State.RESETING) {
+ if (getObservableData(mState) == State.RESETTING) {
resetInternal();
} else {
- setState(State.IDLING);
+ // Reset the internal state to idling, except when the error is with an recorder
+ // error, which can't be recovered without reinitializing the recorder.
+ if (error != VideoRecordEvent.ERROR_RECORDER_ERROR) {
+ setState(State.IDLING);
+ }
}
}
}