You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

  1. From 6b3250a3fb4a854d19980868ed187ca21f0e5ed8 Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Mon, 3 Feb 2020 15:26:50 -0800
  4. Subject: [PATCH] volume_mapping: get rid of exp10 workaround
  5. exp10 is a GNU function, is not part of C++, and is not available
  6. everywhere.
  7. pow(10,x) is an alternative that works just as well.
  8. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  9. ---
  10. src/mixer/plugins/volume_mapping.c | 11 +++--------
  11. 1 file changed, 3 insertions(+), 8 deletions(-)
  12. diff --git a/src/mixer/plugins/volume_mapping.c b/src/mixer/plugins/volume_mapping.c
  13. index 61a7138af..beecce640 100644
  14. --- a/src/mixer/plugins/volume_mapping.c
  15. +++ b/src/mixer/plugins/volume_mapping.c
  16. @@ -34,11 +34,6 @@
  17. #include <stdbool.h>
  18. #include "volume_mapping.h"
  19. -#ifdef __UCLIBC__
  20. -/* 10^x = 10^(log e^x) = (e^x)^log10 = e^(x * log 10) */
  21. -#define exp10(x) (exp((x) * log(10)))
  22. -#endif /* __UCLIBC__ */
  23. -
  24. #define MAX_LINEAR_DB_SCALE 24
  25. static inline bool use_linear_dB_scale(long dBmin, long dBmax)
  26. @@ -111,9 +106,9 @@ static double get_normalized_volume(snd_mixer_elem_t *elem,
  27. if (use_linear_dB_scale(min, max))
  28. return (value - min) / (double)(max - min);
  29. - normalized = exp10((value - max) / 6000.0);
  30. + normalized = pow(10, (value - max) / 6000.0);
  31. if (min != SND_CTL_TLV_DB_GAIN_MUTE) {
  32. - min_norm = exp10((min - max) / 6000.0);
  33. + min_norm = pow(10, (min - max) / 6000.0);
  34. normalized = (normalized - min_norm) / (1 - min_norm);
  35. }
  36. @@ -159,7 +154,7 @@ static int set_normalized_volume(snd_mixer_elem_t *elem,
  37. }
  38. if (min != SND_CTL_TLV_DB_GAIN_MUTE) {
  39. - min_norm = exp10((min - max) / 6000.0);
  40. + min_norm = pow(10, (min - max) / 6000.0);
  41. volume = volume * (1 - min_norm) + min_norm;
  42. }
  43. value = lrint_dir(6000.0 * log10(volume), dir) + max;