From 0a51980f26d459764f5bcb859aa8e66aed9d9e06 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Mon, 21 Aug 2023 14:45:48 +0200 Subject: [PATCH] fix: Use default HDR if not applicable --- .../camera/extensions/CameraDevice+createCaptureSession.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/mrousavy/camera/extensions/CameraDevice+createCaptureSession.kt b/android/src/main/java/com/mrousavy/camera/extensions/CameraDevice+createCaptureSession.kt index 5073d29..aaccebc 100644 --- a/android/src/main/java/com/mrousavy/camera/extensions/CameraDevice+createCaptureSession.kt +++ b/android/src/main/java/com/mrousavy/camera/extensions/CameraDevice+createCaptureSession.kt @@ -77,10 +77,12 @@ suspend fun CameraDevice.createCaptureSession(cameraManager: CameraManager, } if (outputs.enableHdr == true && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { val supportedProfiles = characteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES) - val hdrProfile = supportedProfiles?.bestProfile + val hdrProfile = supportedProfiles?.bestProfile ?: supportedProfiles?.supportedProfiles?.firstOrNull() if (hdrProfile != null) { Log.i(TAG, "Camera $id: Using HDR Profile $hdrProfile...") outputConfigurations.forEach { it.dynamicRangeProfile = hdrProfile } + } else { + Log.w(TAG, "Camera $id: HDR was enabled, but the device does not support any matching HDR profile!") } }