aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_utils.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-19 21:00:50 +0100
committerMax Kellermann <max@duempel.org>2009-11-19 21:00:50 +0100
commit135842803156ab3d983babb61d22905a43977be3 (patch)
tree4087984407caa2361118950238fa8672dce94aa1 /src/pcm_utils.h
parent5a480137d2c724c8a3359c66a9120e310ea19cd1 (diff)
downloadmpd-135842803156ab3d983babb61d22905a43977be3.tar.gz
mpd-135842803156ab3d983babb61d22905a43977be3.tar.xz
mpd-135842803156ab3d983babb61d22905a43977be3.zip
pcm_volume: implemented 32 bit support
Support 32 bit samples with software mixer.
Diffstat (limited to 'src/pcm_utils.h')
-rw-r--r--src/pcm_utils.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pcm_utils.h b/src/pcm_utils.h
index 93f414231..8b2259655 100644
--- a/src/pcm_utils.h
+++ b/src/pcm_utils.h
@@ -38,4 +38,18 @@ pcm_range(int32_t sample, unsigned bits)
return sample;
}
+/**
+ * Check if the value is within the range of the provided bit size,
+ * and caps it if necessary.
+ */
+static inline int64_t
+pcm_range_64(int64_t sample, unsigned bits)
+{
+ if (G_UNLIKELY(sample < ((int64_t)-1 << (bits - 1))))
+ return (int64_t)-1 << (bits - 1);
+ if (G_UNLIKELY(sample >= ((int64_t)1 << (bits - 1))))
+ return ((int64_t)1 << (bits - 1)) - 1;
+ return sample;
+}
+
#endif