From 3a0f3eaa50c748e2a8e42f15beb4bf447fa1a87c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 2 Dec 2013 09:09:19 +0100 Subject: pcm/PcmUtils: use the SampleTraits library --- src/pcm/PcmUtils.hxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/pcm/PcmUtils.hxx') diff --git a/src/pcm/PcmUtils.hxx b/src/pcm/PcmUtils.hxx index 108ba85ae..06b3acb4d 100644 --- a/src/pcm/PcmUtils.hxx +++ b/src/pcm/PcmUtils.hxx @@ -26,6 +26,9 @@ #include +enum class SampleFormat : uint8_t; +template struct SampleTraits; + /** * Add a byte count to the specified pointer. This is a utility * function to convert a source pointer and a byte count to an "end" @@ -42,13 +45,15 @@ pcm_end_pointer(const T *p, size_t size) * Check if the value is within the range of the provided bit size, * and caps it if necessary. */ -template +template> gcc_const -static inline T -PcmClamp(U x) +static inline typename Traits::value_type +PcmClamp(typename Traits::long_type x) { - constexpr U MIN_VALUE = -(U(1) << (bits - 1)); - constexpr U MAX_VALUE = (U(1) << (bits - 1)) - 1; + typedef typename Traits::value_type T; + typedef typename Traits::long_type U; + constexpr U MIN_VALUE = -(U(1) << (Traits::BITS - 1)); + constexpr U MAX_VALUE = (U(1) << (Traits::BITS - 1)) - 1; typedef std::numeric_limits limits; static_assert(MIN_VALUE >= limits::min(), "out of range"); -- cgit v1.2.3