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:
parent
cd0b413706
commit
62ca95725d
@ -226,22 +226,23 @@ 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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user