livoxGen1: add n-dgrams-per-frame param

This commit is contained in:
2025-11-15 22:12:48 -04:00
parent b3743560bb
commit bed10df499
2 changed files with 42 additions and 4 deletions
+33 -1
View File
@@ -109,6 +109,35 @@ static int parseHistbuffMs(
return histbuffMs;
}
// Helper function to parse n-dgrams-per-frame from stim-buff-api params
static size_t parseNDgramsPerFrame(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
{
size_t nDgramsPerFrame = 30; // Default: 30 datagrams per frame
const std::vector<std::string> nDgramsPerFrameParamNames = {
"n-dgrams-per-frame",
"num-dgrams-per-frame"
};
// Loop through synonyms in reverse order; lattermost synonym wins.
for (auto synIt = nDgramsPerFrameParamNames.rbegin();
synIt != nDgramsPerFrameParamNames.rend(); ++synIt)
{
const auto& paramName = *synIt;
try {
nDgramsPerFrame = static_cast<size_t>(
smo::device::DeviceAttachmentSpec::parseRequiredParamAsInt(
spec->stimBuffApiParams, paramName));
break; // Found and parsed successfully
} catch (const std::exception&) {
// Parameter not found or parse error, continue to next synonym
continue;
}
}
return nDgramsPerFrame;
}
// LivoxProto1DllState constructor implementation
LivoxProto1DllState::LivoxProto1DllState()
: dlopenHandle(nullptr, DlCloser),
@@ -282,8 +311,11 @@ public:
formatDesc.format = PcloudStimulusProducer::PcloudFormatDesc::Format
::XYZI;
// Parse n-dgrams-per-frame from stim-buff-api params (default: 30)
size_t nDgramsPerFrame = parseNDgramsPerFrame(context->spec);
auto pcloudDataProducer = std::make_shared<PcloudStimulusProducer>(
context->spec, context->deviceTmp, formatDesc, 30);
context->spec, context->deviceTmp, formatDesc, nDgramsPerFrame);
context->stimProducer = pcloudDataProducer;
context->deviceTmp->nAttachedStimulusProducers++;