diff options
author | Max Kellermann <max@duempel.org> | 2008-11-11 16:29:02 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-11 16:29:02 +0100 |
commit | ad77a3e0ace2bb082bc619de1c6d8732715e8977 (patch) | |
tree | 7068492d1cc15419a613acb00953760fee64f99c /src | |
parent | 5ddde0aac790c57b75f20ce71e100f4379f1c653 (diff) | |
download | mpd-ad77a3e0ace2bb082bc619de1c6d8732715e8977.tar.gz mpd-ad77a3e0ace2bb082bc619de1c6d8732715e8977.tar.xz mpd-ad77a3e0ace2bb082bc619de1c6d8732715e8977.zip |
pcm_utils: added inline function pcm_float_to_volume()
Diffstat (limited to 'src')
-rw-r--r-- | src/pcm_utils.h | 10 | ||||
-rw-r--r-- | src/volume.c | 5 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/pcm_utils.h b/src/pcm_utils.h index 1668bbf0c..069fb9f53 100644 --- a/src/pcm_utils.h +++ b/src/pcm_utils.h @@ -36,6 +36,16 @@ struct pcm_convert_state { int error; }; +/** + * Converts a float value (0.0 = silence, 1.0 = 100% volume) to an + * integer volume value (1000 = 100%). + */ +static inline int +pcm_float_to_volume(float volume) +{ + return volume * 1000.0 + 0.5; +} + void pcm_volume(char *buffer, int bufferSize, const struct audio_format *format, int volume); diff --git a/src/volume.c b/src/volume.c index 8e27dae38..8d497ed44 100644 --- a/src/volume.c +++ b/src/volume.c @@ -22,6 +22,7 @@ #include "player_control.h" #include "utils.h" #include "idle.h" +#include "pcm_utils.h" #include "os_compat.h" #include "../config.h" @@ -483,8 +484,8 @@ static int changeSoftwareVolume(int change, int rel) else if (new <= 0) new = 0; else - new = - 1000.0 * (exp(new / 25.0) - 1) / (54.5981500331F - 1) + 0.5; + new = pcm_float_to_volume((exp(new / 25.0) - 1) / + (54.5981500331F - 1)); setPlayerSoftwareVolume(new); |