From ad77a3e0ace2bb082bc619de1c6d8732715e8977 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 11 Nov 2008 16:29:02 +0100 Subject: pcm_utils: added inline function pcm_float_to_volume() --- src/pcm_utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/pcm_utils.h') 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); -- cgit v1.2.3