diff --git a/src/client/videomanager.cpp b/src/client/videomanager.cpp index 7f7f5a21457abe342baa4289e71eeb5049ff6145..dcb3a29265ae5eb28409c6b01e5e85b1c7907f23 100644 --- a/src/client/videomanager.cpp +++ b/src/client/videomanager.cpp @@ -44,6 +44,7 @@ #include <string> #include <vector> #include <new> // std::bad_alloc +#include <algorithm> #include <cstdlib> #include <cstring> // std::memset #include <ciso646> // fix windows compiler bug @@ -162,10 +163,9 @@ AudioFrame::mix(const AudioFrame& frame) auto c = (int16_t*)f.extended_data[i]; auto cIn = (int16_t*)fIn.extended_data[i]; for (unsigned s=0; s < samplesPerChannel; s++) { - int32_t n = (int32_t)c[s] + (int32_t)cIn[s]; - n = std::min<int32_t>(n, std::numeric_limits<int16_t>::max()); - n = std::max<int32_t>(n, std::numeric_limits<int16_t>::min()); - c[s] = n; + c[s] = std::clamp((int32_t)c[s] + (int32_t)cIn[s], + (int32_t)std::numeric_limits<int16_t>::min(), + (int32_t)std::numeric_limits<int16_t>::max()); } } } else if (fmt == AV_SAMPLE_FMT_FLT || fmt == AV_SAMPLE_FMT_FLTP) {