aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-12-22 17:37:36 +0100
committerMax Kellermann <max@duempel.org>2013-12-22 21:31:17 +0100
commit316a25dead0698be5e5befb236e08146740aca77 (patch)
tree84e2857b781ca27658cb41e77301233bfef21655
parentbfe020e06c2ba0671cdd1dacd9999c986c3168d6 (diff)
downloadmpd-316a25dead0698be5e5befb236e08146740aca77.tar.gz
mpd-316a25dead0698be5e5befb236e08146740aca77.tar.xz
mpd-316a25dead0698be5e5befb236e08146740aca77.zip
pcm/Volume: add constant PCM_VOLUME_BITS
-rw-r--r--src/pcm/PcmVolume.cxx2
-rw-r--r--src/pcm/PcmVolume.hxx5
2 files changed, 6 insertions, 1 deletions
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<F, Traits>(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
@@ -27,6 +27,11 @@
#include <stddef.h>
/**
+ * Number of fractional bits for a fixed-point volume value.
+ */
+static constexpr unsigned PCM_VOLUME_BITS = 10;
+
+/**
* This value means "100% volume".
*/
static constexpr unsigned PCM_VOLUME_1 = 1024;