Skip to contentSkip to conversation

amixer: Fix convert_prange1 not rounding correctly

PATCH New Josef Gajdusek 1 participant 1 message Jul 6, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amixer: Fix convert_prange1 not rounding correctly

The convert_prange1 macro was not the exact inverse of convert_prange. This was causing the volume percentage set by 'amixer set' to differ from the one displayed by 'amixer get'.

---
 amixer/amixer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
amixer/amixer.c +1 -1
index cf82892..577a2ca 100644
@@ -201,7 +201,7 @@ static int convert_prange(long val, long min, long max)
 /* Function to convert from percentage to volume. val = percentage */
 
 #define convert_prange1(val, min, max) \
-	ceil((val) * ((max) - (min)) * 0.01 + (min))
+	rint((val) * ((max) - (min)) * 0.01 + (min))
 
 struct volume_ops {
 	int (*get_range)(snd_mixer_elem_t *elem, long *min, long *max);
Signature · 1 line
1.8.5.5