Browse Source

Use clamp in Port::getNumInputs/Outputs().

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
09030e0299
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      src/audio.cpp

+ 3
- 2
src/audio.cpp View File

@@ -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());


Loading…
Cancel
Save