Aperture: Frame rates lists should be unordered sets
Change-Id: Ie3154f7c11fa424edd50f162548ed236774078b6
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
index 692b7b2..0c314be 100644
--- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
@@ -207,9 +207,9 @@
// Video
private val supportedVideoQualities: List<Quality>
get() = camera.supportedVideoQualities.keys.toList()
- private val supportedVideoFrameRates: List<FrameRate>
+ private val supportedVideoFrameRates: Set<FrameRate>
get() = camera.supportedVideoQualities.getOrDefault(
- sharedPreferences.videoQuality, listOf()
+ sharedPreferences.videoQuality, setOf()
)
private lateinit var audioConfig: AudioConfig
private var recording: Recording? = null
@@ -1373,7 +1373,8 @@
}
val currentVideoFrameRate = sharedPreferences.videoFrameRate
- val newVideoFrameRate = supportedVideoFrameRates.next(currentVideoFrameRate)
+ val newVideoFrameRate = supportedVideoFrameRates.toList().sorted()
+ .next(currentVideoFrameRate)
if (newVideoFrameRate == currentVideoFrameRate) {
return
diff --git a/app/src/main/java/org/lineageos/aperture/camera/Camera.kt b/app/src/main/java/org/lineageos/aperture/camera/Camera.kt
index c2a5d66..731373a 100644
--- a/app/src/main/java/org/lineageos/aperture/camera/Camera.kt
+++ b/app/src/main/java/org/lineageos/aperture/camera/Camera.kt
@@ -47,7 +47,7 @@
private val supportedVideoFrameRates = cameraInfo.supportedFrameRateRanges.mapNotNull {
FrameRate.fromRange(it)
- }.distinct().sorted()
+ }.toSet()
val supportedVideoQualities =
Recorder.getVideoCapabilities(cameraInfo).getSupportedQualities(DynamicRange.SDR)
.associateWith {
diff --git a/app/src/main/java/org/lineageos/aperture/camera/CameraManager.kt b/app/src/main/java/org/lineageos/aperture/camera/CameraManager.kt
index 9a19263..1d9edeb 100644
--- a/app/src/main/java/org/lineageos/aperture/camera/CameraManager.kt
+++ b/app/src/main/java/org/lineageos/aperture/camera/CameraManager.kt
@@ -26,7 +26,7 @@
val cameraExecutor: ExecutorService = Executors.newSingleThreadExecutor()
private val additionalVideoConfigurations by lazy {
- mutableMapOf<String, MutableMap<Quality, MutableList<FrameRate>>>().apply {
+ mutableMapOf<String, MutableMap<Quality, MutableSet<FrameRate>>>().apply {
context.resources.getStringArray(context, R.array.config_additionalVideoConfigurations)
.let {
if (it.size % 3 != 0) {
@@ -53,7 +53,7 @@
this[cameraId] = mutableMapOf()
}
if (!this[cameraId]!!.containsKey(it)) {
- this[cameraId]!![it] = mutableListOf()
+ this[cameraId]!![it] = mutableSetOf()
}
this[cameraId]!![it]!!.addAll(frameRates)
}
@@ -146,7 +146,7 @@
get() = availableCameras.filter { it.supportsVideoRecording }
fun getAdditionalVideoFrameRates(cameraId: String, quality: Quality) =
- additionalVideoConfigurations[cameraId]?.get(quality) ?: listOf()
+ additionalVideoConfigurations[cameraId]?.get(quality) ?: setOf()
fun getLogicalZoomRatios(cameraId: String) = mutableMapOf(1.0f to 1.0f).apply {
logicalZoomRatios[cameraId]?.let {
diff --git a/app/src/main/java/org/lineageos/aperture/camera/FrameRate.kt b/app/src/main/java/org/lineageos/aperture/camera/FrameRate.kt
index f2ac049..d066ba6 100644
--- a/app/src/main/java/org/lineageos/aperture/camera/FrameRate.kt
+++ b/app/src/main/java/org/lineageos/aperture/camera/FrameRate.kt
@@ -19,7 +19,7 @@
* Get the closer frame rate to the requested one, first finding a lower one
* then checking for a higher one if no one exists.
*/
- fun getLowerOrHigher(frameRates: List<FrameRate>): FrameRate? {
+ fun getLowerOrHigher(frameRates: Collection<FrameRate>): FrameRate? {
val smaller = frameRates.filter { it <= this }.sortedDescending()
val bigger = frameRates.filter { it > this }.sorted()