From 6c614d7e6c06e5d24242e2703028c58704495790 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Tue, 11 Oct 2022 10:05:28 +0200 Subject: [PATCH] Added check, that for duplex mode both in- and output channels should be enabled --- src/lasp/device/lasp_daq.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/lasp/device/lasp_daq.cpp b/src/lasp/device/lasp_daq.cpp index 158ac04..a5d1bd5 100644 --- a/src/lasp/device/lasp_daq.cpp +++ b/src/lasp/device/lasp_daq.cpp @@ -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::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); }