Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] amixer: Fix convert_prange1 not rounding correctly
@ 2014-07-06 18:25 Josef Gajdusek
  0 siblings, 0 replies; only message in thread
From: Josef Gajdusek @ 2014-07-06 18:25 UTC (permalink / raw)
  To: patch; +Cc: alsa-devel

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'.

Signed-off-by: Josef Gajdusek <atx@atx.name>
---
 amixer/amixer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/amixer/amixer.c b/amixer/amixer.c
index cf82892..577a2ca 100644
--- a/amixer/amixer.c
+++ b/amixer/amixer.c
@@ -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);
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-06 18:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-06 18:25 [PATCH] amixer: Fix convert_prange1 not rounding correctly Josef Gajdusek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox