From 316a25dead0698be5e5befb236e08146740aca77 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 22 Dec 2013 17:37:36 +0100 Subject: [PATCH] pcm/Volume: add constant PCM_VOLUME_BITS --- src/pcm/PcmVolume.cxx | 2 +- src/pcm/PcmVolume.hxx | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pcm/PcmVolume.cxx b/src/pcm/PcmVolume.cxx index d2a3c51f3..5c0a1fbd3 100644 --- a/src/pcm/PcmVolume.cxx +++ b/src/pcm/PcmVolume.cxx @@ -37,7 +37,7 @@ pcm_volume_change(typename Traits::pointer_type buffer, sample = (sample * volume + pcm_volume_dither() + PCM_VOLUME_1S / 2) - / PCM_VOLUME_1S; + >> PCM_VOLUME_BITS; *buffer++ = PcmClamp(sample); } diff --git a/src/pcm/PcmVolume.hxx b/src/pcm/PcmVolume.hxx index 502fca9ec..52102a294 100644 --- a/src/pcm/PcmVolume.hxx +++ b/src/pcm/PcmVolume.hxx @@ -26,6 +26,11 @@ #include #include +/** + * Number of fractional bits for a fixed-point volume value. + */ +static constexpr unsigned PCM_VOLUME_BITS = 10; + /** * This value means "100% volume". */