summaryrefslogtreecommitdiff
path: root/src/mixer
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2020-02-03 15:26:50 -0800
committerRosen Penev <rosenp@gmail.com>2020-03-15 20:17:31 -0700
commita78841d6a953c4f40e8196e51bdd4aad995b9104 (patch)
tree796c697ee336ecfd5da50952dded2899499b161c /src/mixer
parent3ec9fcfc443a68c9f57e0314c47e70ca02a32530 (diff)
volume_mapping: get rid of exp10 workaround
exp10 is a GNU function, is not part of C++, and is not available everywhere. pow(10,x) is an alternative that works just as well. It is used in musl as the implementation of exp10. Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'src/mixer')
-rw-r--r--src/mixer/plugins/volume_mapping.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/mixer/plugins/volume_mapping.c b/src/mixer/plugins/volume_mapping.c
index 61a7138af..beecce640 100644
--- a/src/mixer/plugins/volume_mapping.c
+++ b/src/mixer/plugins/volume_mapping.c
@@ -34,11 +34,6 @@
#include <stdbool.h>
#include "volume_mapping.h"
-#ifdef __UCLIBC__
-/* 10^x = 10^(log e^x) = (e^x)^log10 = e^(x * log 10) */
-#define exp10(x) (exp((x) * log(10)))
-#endif /* __UCLIBC__ */
-
#define MAX_LINEAR_DB_SCALE 24
static inline bool use_linear_dB_scale(long dBmin, long dBmax)
@@ -111,9 +106,9 @@ static double get_normalized_volume(snd_mixer_elem_t *elem,
if (use_linear_dB_scale(min, max))
return (value - min) / (double)(max - min);
- normalized = exp10((value - max) / 6000.0);
+ normalized = pow(10, (value - max) / 6000.0);
if (min != SND_CTL_TLV_DB_GAIN_MUTE) {
- min_norm = exp10((min - max) / 6000.0);
+ min_norm = pow(10, (min - max) / 6000.0);
normalized = (normalized - min_norm) / (1 - min_norm);
}
@@ -159,7 +154,7 @@ static int set_normalized_volume(snd_mixer_elem_t *elem,
}
if (min != SND_CTL_TLV_DB_GAIN_MUTE) {
- min_norm = exp10((min - max) / 6000.0);
+ min_norm = pow(10, (min - max) / 6000.0);
volume = volume * (1 - min_norm) + min_norm;
}
value = lrint_dir(6000.0 * log10(volume), dir) + max;