fix: Fix torch not turning off after it has been enabled (#1997)

fix: Fix torch and low-light boost not turning off again
This commit is contained in:
Marc Rousavy 2023-10-13 18:44:44 +02:00 committed by GitHub
parent cd0b413706
commit 62ca95725d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -226,24 +226,25 @@ extension CameraSession {
} }
// Configure Low-Light-Boost // Configure Low-Light-Boost
if configuration.enableLowLightBoost { if device.automaticallyEnablesLowLightBoostWhenAvailable != configuration.enableLowLightBoost {
let isDifferent = configuration.enableLowLightBoost != device.automaticallyEnablesLowLightBoostWhenAvailable guard device.isLowLightBoostSupported else {
if isDifferent && !device.isLowLightBoostSupported {
throw CameraError.device(.lowLightBoostNotSupported) throw CameraError.device(.lowLightBoostNotSupported)
} }
device.automaticallyEnablesLowLightBoostWhenAvailable = configuration.enableLowLightBoost device.automaticallyEnablesLowLightBoostWhenAvailable = configuration.enableLowLightBoost
} }
// Configure Torch // Configure Torch
if configuration.torch != .off { let torchMode = configuration.torch.toTorchMode()
if device.torchMode != torchMode {
guard device.hasTorch else { guard device.hasTorch else {
throw CameraError.device(.flashUnavailable) throw CameraError.device(.flashUnavailable)
} }
device.torchMode = torchMode
device.torchMode = configuration.torch.toTorchMode() if torchMode == .on {
try device.setTorchModeOn(level: 1.0) try device.setTorchModeOn(level: 1.0)
} }
} }
}
// pragma MARK: Zoom // pragma MARK: Zoom