-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[camera_windows] Improve several error handling scenarios #6149
Conversation
|
|
||
| void CaptureControllerImpl::ResetCaptureController() { | ||
| if (record_handler_) { | ||
| if (record_handler_ && record_handler_->CanStop()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously IsContinuousRecording and IsTimedRecording could return true even if the recording has stopped. This caused the destructor to try to stop recording again even though recording was already stopped.
| // process. | ||
| if (!record_handler_->StopRecord(capture_engine_.Get())) { | ||
| // Destroy record handler on error cases to make sure state is resetted. | ||
| record_handler_ = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OnRecordStopped does nothing if record_handler_ is null, causing errors to be dropped. Also, OnRecordStopped cleans up the record handler properly.
| assert(capture_engine_); | ||
|
|
||
| if (!IsInitialized() && !preview_handler_) { | ||
| if (!IsInitialized() || !preview_handler_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was incorrect and caused a crash if you attempted to pause/resume/stop a preview that wasn't started.
|
|
||
| enum class RecordingType { | ||
| // Camera is not recording. | ||
| kNone, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new state was added so that IsContinuousRecording and IsTimedRecording returns false if the recording isn't running or stopping. Technically this could've been achieved by checking recording_state_, but, I'd rather have type_ be a sensible value if the recording is stopped or not started.
bde05fd to
a02193b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
93e539b to
2b4dd7c
Compare
a-wallen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
2b4dd7c to
497e0e7
Compare
This change improves
camera_windows's error handling:CaptureControllerImpl's destructor no longer tries to stop recording even if recording has already stopped.Part of flutter/flutter#102098
List which issues are fixed by this PR. You must list at least one issue.
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.