From 09030e0299720bfca54b094d310bd37cf5cc998e Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 22 Sep 2021 06:45:07 -0400 Subject: [PATCH] Use clamp in Port::getNumInputs/Outputs(). --- src/audio.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/audio.cpp b/src/audio.cpp index 49b29d0b..7079df02 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace rack { @@ -288,7 +289,7 @@ int Port::getNumInputs() { if (!device) return 0; try { - return std::min(std::max(device->getNumInputs() - inputOffset, 0), maxInputs); + return math::clamp(device->getNumInputs() - inputOffset, 0, maxInputs); } catch (Exception& e) { WARN("Audio port could not get device number of inputs: %s", e.what()); @@ -300,7 +301,7 @@ int Port::getNumOutputs() { if (!device) return 0; try { - return std::min(std::max(device->getNumOutputs() - outputOffset, 0), maxOutputs); + return math::clamp(device->getNumOutputs() - outputOffset, 0, maxOutputs); } catch (Exception& e) { WARN("Audio port could not get device number of outputs: %s", e.what());