livoxGen1:PcloudStimProd: move qualeApi param parsing here

This commit is contained in:
2025-11-16 04:38:25 -04:00
parent 44435c61eb
commit 3bcb83894b
4 changed files with 39 additions and 41 deletions
+1 -35
View File
@@ -80,37 +80,6 @@ getStimulusProducer(
return nullptr;
}
// Helper function to parse histbuffMs from device attachment spec
static int parseHistbuffMs(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
{
int histbuffMs = 30000; // Default: 30000ms (30 seconds)
const std::vector<std::string> histbuffParamNames = {
"history-buffer-duration-ms",
"hist-buff-duration-ms",
"histbuff-duration-ms",
"histbuff-ms"
};
// Loop through synonyms in reverse order; lattermost synonym wins.
for (auto synIt = histbuffParamNames.rbegin();
synIt != histbuffParamNames.rend(); ++synIt)
{
const auto& paramName = *synIt;
try {
histbuffMs = smo::device::DeviceAttachmentSpec
::parseRequiredParamAsInt(
spec->qualeIfaceApiParams, paramName);
break; // Found and parsed successfully
} catch (const std::exception&) {
// Parameter not found or parse error, continue to next synonym
continue;
}
}
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)
@@ -205,13 +174,10 @@ private:
return false;
}
// Parse histbuffMs
int histbuffMs = parseHistbuffMs(context->spec);
// Call getOrCreateAttachedStimulusBuffer (may throw, catch and return failure)
try {
context->stimProducer->getOrCreateAttachedStimulusBuffer(
context->spec, histbuffMs);
context->spec);
} catch (const std::exception& e) {
std::cerr << __func__ << ": Failed to create StimBuffer: "
<< e.what() << ". Producer is committed, DeviceReattacher will retry."