Added check, that for duplex mode both in- and output channels should be enabled

This commit is contained in:
Anne de Jong 2022-10-11 10:05:28 +02:00
parent 84a0d11d43
commit 6c614d7e6c

View File

@ -9,7 +9,7 @@
#if LASP_HAS_RTAUDIO == 1
#include "lasp_rtaudiodaq.h"
#endif
using std::runtime_error;
using rte = std::runtime_error;
Daq::~Daq() { DEBUGTRACE_ENTER; }
@ -28,28 +28,37 @@ std::unique_ptr<Daq> Daq::createDaq(const DeviceInfo &devinfo,
return createRtAudioDevice(devinfo, config);
}
#endif
throw std::runtime_error(string("Unable to match Device API: ") +
devinfo.api.apiname);
throw rte(string("Unable to match Device API: ") + devinfo.api.apiname);
}
Daq::Daq(const DeviceInfo &devinfo, const DaqConfiguration &config)
: DaqConfiguration(config), DeviceInfo(devinfo) {
DEBUGTRACE_ENTER;
if (duplexMode()) {
if (neninchannels() == 0) {
throw rte("Duplex mode enabled, but no input channels enabled");
}
if (nenoutchannels() == 0) {
throw rte("Duplex mode enabled, but no output channels enabled");
}
}
if (!hasInternalOutputMonitor && monitorOutput) {
throw std::runtime_error(
throw rte(
"Output monitor flag set, but device does not have output monitor");
}
if (!config.match(devinfo)) {
throw std::runtime_error("DaqConfiguration does not match device info");
throw rte("DaqConfiguration does not match device info");
}
if (neninchannels(false) > ninchannels) {
throw std::runtime_error(
throw rte(
"Number of enabled input channels is higher than device capability");
}
if (nenoutchannels() > noutchannels) {
throw std::runtime_error(
throw rte(
"Number of enabled output channels is higher than device capability");
}
}
@ -68,7 +77,7 @@ const DataTypeDescriptor &Daq::dtypeDescr() const {
double Daq::inputRangeForChannel(us ch) const {
if (!(ch < ninchannels)) {
throw runtime_error("Invalid channel number");
throw rte("Invalid channel number");
}
return availableInputRanges.at(inchannel_config[ch].rangeIndex);
}