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
if configuration.enableLowLightBoost {
let isDifferent = configuration.enableLowLightBoost != device.automaticallyEnablesLowLightBoostWhenAvailable
if isDifferent && !device.isLowLightBoostSupported {
if device.automaticallyEnablesLowLightBoostWhenAvailable != configuration.enableLowLightBoost {
guard device.isLowLightBoostSupported else {
throw CameraError.device(.lowLightBoostNotSupported)
}
device.automaticallyEnablesLowLightBoostWhenAvailable = configuration.enableLowLightBoost
}
// Configure Torch
if configuration.torch != .off {
let torchMode = configuration.torch.toTorchMode()
if device.torchMode != torchMode {
guard device.hasTorch else {
throw CameraError.device(.flashUnavailable)
}
device.torchMode = configuration.torch.toTorchMode()
device.torchMode = torchMode
if torchMode == .on {
try device.setTorchModeOn(level: 1.0)
}
}
}
// pragma MARK: Zoom