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