| @@ -1,5 +1,6 @@ | |||||
| #include <audio.hpp> | #include <audio.hpp> | ||||
| #include <string.hpp> | #include <string.hpp> | ||||
| #include <math.hpp> | |||||
| namespace rack { | namespace rack { | ||||
| @@ -288,7 +289,7 @@ int Port::getNumInputs() { | |||||
| if (!device) | if (!device) | ||||
| return 0; | return 0; | ||||
| try { | try { | ||||
| return std::min(std::max(device->getNumInputs() - inputOffset, 0), maxInputs); | |||||
| return math::clamp(device->getNumInputs() - inputOffset, 0, maxInputs); | |||||
| } | } | ||||
| catch (Exception& e) { | catch (Exception& e) { | ||||
| WARN("Audio port could not get device number of inputs: %s", e.what()); | WARN("Audio port could not get device number of inputs: %s", e.what()); | ||||
| @@ -300,7 +301,7 @@ int Port::getNumOutputs() { | |||||
| if (!device) | if (!device) | ||||
| return 0; | return 0; | ||||
| try { | try { | ||||
| return std::min(std::max(device->getNumOutputs() - outputOffset, 0), maxOutputs); | |||||
| return math::clamp(device->getNumOutputs() - outputOffset, 0, maxOutputs); | |||||
| } | } | ||||
| catch (Exception& e) { | catch (Exception& e) { | ||||
| WARN("Audio port could not get device number of outputs: %s", e.what()); | WARN("Audio port could not get device number of outputs: %s", e.what()); | ||||