fix: Fix setting FPS lower than 30 on Samsung devices (#2138)

This commit is contained in:
Marc Rousavy 2023-11-09 11:56:20 +01:00 committed by GitHub
parent 1d13db25e9
commit bb59c0a3b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,7 +61,7 @@ class CameraSession(private val context: Context, private val cameraManager: Cam
private const val TAG = "CameraSession"
// TODO: Samsung advertises 60 FPS but only allows 30 FPS for some reason.
private val CAN_SET_FPS = !Build.MANUFACTURER.equals("samsung", true)
private val CAN_DO_60_FPS = !Build.MANUFACTURER.equals("samsung", true)
}
// Camera Configuration
@ -394,8 +394,12 @@ class CameraSession(private val context: Context, private val cameraManager: Cam
// Set FPS
// TODO: Check if the FPS range is actually supported in the current configuration.
val fps = config.fps
if (fps != null && CAN_SET_FPS) {
var fps = config.fps
if (fps != null) {
if (!CAN_DO_60_FPS) {
// If we can't do 60 FPS, we clamp it to 30 FPS - that's always supported.
fps = Math.min(30, fps)
}
captureRequest.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, Range(fps, fps))
}