From 738254b2fcce62e9e0016768e5a4ee0cec0691f7 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max.kellermann@gmail.com>
Date: Mon, 13 Mar 2023 12:38:48 +0100
Subject: [PATCH] pcm/Normalizer: use SampleTraits

---
 src/pcm/Normalizer.cxx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/pcm/Normalizer.cxx b/src/pcm/Normalizer.cxx
index ed275af64..ab9c67e04 100644
--- a/src/pcm/Normalizer.cxx
+++ b/src/pcm/Normalizer.cxx
@@ -11,6 +11,7 @@ void
 PcmNormalizer::ProcessS16(int16_t *audio, std::size_t count) noexcept
 {
 	constexpr SampleFormat format = SampleFormat::S16;
+	using Traits = SampleTraits<format>;
 
         const int slot = (pos + 1) % bufsz;
 
@@ -52,9 +53,9 @@ PcmNormalizer::ProcessS16(int16_t *audio, std::size_t count) noexcept
 
         //! Make sure the adjusted gain won't cause clipping
         std::size_t ramp = count;
-        if ((peakVal*newGain >> 10) > 32767)
+        if ((peakVal*newGain >> 10) > Traits::MAX)
         {
-                newGain = (32767 << 10)/peakVal;
+                newGain = (Traits::MAX << 10)/peakVal;
                 //! Truncate the ramp time
                 ramp = peakPos;
         }