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
@@ -106,6 +106,37 @@ void produceStimFrameAck(void)
{
}
// Helper function to parse histbuffMs from device attachment spec
static int parseHistbuffMs(
const std::shared_ptr<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 = 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;
}
std::shared_ptr<StimulusBuffer>
PcloudStimulusProducer::getAttachedStimulusBuffer(
const std::shared_ptr<device::DeviceAttachmentSpec>& spec) const
@@ -142,8 +173,7 @@ PcloudStimulusProducer::getAttachedStimulusBuffer(
std::shared_ptr<StimulusBuffer>
PcloudStimulusProducer::getOrCreateAttachedStimulusBuffer(
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec,
int histbuffMs
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec
)
{
// Check if buffer already exists (idempotent)
@@ -151,6 +181,9 @@ PcloudStimulusProducer::getOrCreateAttachedStimulusBuffer(
if (existingBuffer)
{ return existingBuffer; }
// Parse histbuffMs from device attachment spec
int histbuffMs = parseHistbuffMs(deviceAttachmentSpec);
// Parse qualeIfaceApi to determine buffer type
const std::string& qualeIfaceApi = deviceAttachmentSpec->qualeIfaceApi;