Skip to content

Commit 93328d2

Browse files
committed
android: fix balance NaN error when amplification L/R is both zero
1 parent 792629a commit 93328d2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

android/app/src/main/java/me/kavishdevar/librepods/screens/AccessibilitySettingsScreen.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,11 @@ private fun parseTransparencySettingsResponse(data: ByteArray): TransparencySett
818818
val avg = (leftAmplification + rightAmplification) / 2
819819
val amplification = avg.coerceIn(0f, 1f)
820820
val diff = rightAmplification - leftAmplification
821-
val balance = (0.5f + diff / (2 * avg)).coerceIn(0f, 1f)
821+
val balance = if (avg == 0f) {
822+
0.5f
823+
} else {
824+
(0.5f + diff / (2 * avg)).coerceIn(0f, 1f)
825+
}
822826

823827
return TransparencySettings(
824828
enabled = enabled > 0.5f,

0 commit comments

Comments
 (0)