aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm/PcmUtils.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-11-23 18:45:02 +0100
committerMax Kellermann <max@duempel.org>2013-11-23 18:45:02 +0100
commit99527051b5751d2ef7c6b593f1beda84d1bcc33f (patch)
tree39b08616c597fc173022164050ed557650c177b5 /src/pcm/PcmUtils.hxx
parentbed98303a346dd98e2a239579c032d170440441d (diff)
parent57e0cc54424561499039967aa501c17d4b179019 (diff)
downloadmpd-99527051b5751d2ef7c6b593f1beda84d1bcc33f.tar.gz
mpd-99527051b5751d2ef7c6b593f1beda84d1bcc33f.tar.xz
mpd-99527051b5751d2ef7c6b593f1beda84d1bcc33f.zip
Merge branch 'v0.18.x'
Diffstat (limited to 'src/pcm/PcmUtils.hxx')
-rw-r--r--src/pcm/PcmUtils.hxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pcm/PcmUtils.hxx b/src/pcm/PcmUtils.hxx
index 108ba85ae..febe12d7b 100644
--- a/src/pcm/PcmUtils.hxx
+++ b/src/pcm/PcmUtils.hxx
@@ -63,4 +63,16 @@ PcmClamp(U x)
return T(x);
}
+/**
+ * Check if the values in this buffer are within the range of the
+ * provided bit size, and clamps them whenever necessary.
+ */
+template<typename T, typename U, unsigned bits>
+static inline void
+PcmClampN(T *dest, const U *src, unsigned n)
+{
+ while (n-- > 0)
+ *dest++ = PcmClamp<T, U, bits>(*src++);
+}
+
#endif