Split StimulusProducer=>StimulusBuffer+StimulusProducer

We're getting ready for the last mile of the StimulusBuffer API
and the proto-completion of the LivoxGen1 StimBuffApi.
This commit is contained in:
2025-11-14 20:44:37 -04:00
parent 70c0175a8b
commit 8a7dc10892
5 changed files with 96 additions and 46 deletions
+15 -18
View File
@@ -23,12 +23,9 @@ PcloudDataProducer::PcloudDataProducer(
const std::shared_ptr<device::DeviceAttachmentSpec> &deviceAttachmentSpec,
std::shared_ptr<livoxProto1::Device> &device,
const PcloudFormatDesc& formatDesc,
int histbuffMs,
size_t nDgramsPerStagingBufferFrame)
: StimulusProducer(
deviceAttachmentSpec,
static_cast<size_t>(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS),
openClInputConstraints,
device->componentThread->getIoService()),
device(device),
formatDesc(formatDesc),
@@ -112,25 +109,25 @@ class PcloudDataProducer::ProduceFrameReq
: public PostedAsynchronousContinuation<produceFrameReqCbFn>
{
private:
PcloudDataProducer& stimBuff;
PcloudDataProducer& pcloudProducer;
AsynchronousLoop frameAssemblyResult;
StimulusFrame& stimulusFrame;
public:
ProduceFrameReq(
PcloudDataProducer& buffer,
PcloudDataProducer& producer,
const std::shared_ptr<ComponentThread>& caller,
Callback<produceFrameReqCbFn> cb)
: PostedAsynchronousContinuation<produceFrameReqCbFn>(caller, cb),
stimBuff(buffer),
pcloudProducer(producer),
frameAssemblyResult(0),
stimulusFrame(buffer.frames_[0])
stimulusFrame(producer.tempStimulusFrame)
{}
public:
void callOriginalCallback()
{
stimBuff.allowNextStimulusFrame();
pcloudProducer.allowNextStimulusFrame();
callOriginalCb();
}
@@ -138,14 +135,14 @@ public:
void produceFrameReq1_doAssemble_posted(
std::shared_ptr<ProduceFrameReq> context)
{
SpinLock::Guard lock(stimBuff.shouldContinueLock);
if (!stimBuff.shouldContinue)
SpinLock::Guard lock(pcloudProducer.shouldContinueLock);
if (!pcloudProducer.shouldContinue)
{
callOriginalCallback();
return;
}
stimBuff.ioUringAssemblyEngine.assembleFrameReq(
pcloudProducer.ioUringAssemblyEngine.assembleFrameReq(
{context, std::bind(
&ProduceFrameReq::produceFrameReq2_assembleDone,
context.get(), context,
@@ -156,8 +153,8 @@ public:
std::shared_ptr<ProduceFrameReq> context,
bool success, AsynchronousLoop loop)
{
SpinLock::Guard lock(stimBuff.shouldContinueLock);
if (!stimBuff.shouldContinue)
SpinLock::Guard lock(pcloudProducer.shouldContinueLock);
if (!pcloudProducer.shouldContinue)
{
callOriginalCallback();
return;
@@ -172,7 +169,7 @@ public:
context->frameAssemblyResult = loop;
stimBuff.openClCollatingAndMeshingEngine.compactCollateAndMeshFrameReq(
pcloudProducer.openClCollatingAndMeshingEngine.compactCollateAndMeshFrameReq(
loop, stimulusFrame,
{context, std::bind(
&ProduceFrameReq::produceFrameReq3_compactCollateDone,
@@ -184,8 +181,8 @@ public:
[[maybe_unused]] std::shared_ptr<ProduceFrameReq> context,
bool success, StimulusFrame& /*stimulusFrame*/)
{
SpinLock::Guard lock(stimBuff.shouldContinueLock);
if (!stimBuff.shouldContinue)
SpinLock::Guard lock(pcloudProducer.shouldContinueLock);
if (!pcloudProducer.shouldContinue)
{
callOriginalCallback();
return;
@@ -198,8 +195,8 @@ public:
}
// Print kernel execution durations
auto compactDuration = stimBuff.openClCollatingAndMeshingEngine.getCompactKernelDuration();
auto collateDuration = stimBuff.openClCollatingAndMeshingEngine.getCollateKernelDuration();
auto compactDuration = pcloudProducer.openClCollatingAndMeshingEngine.getCompactKernelDuration();
auto collateDuration = pcloudProducer.openClCollatingAndMeshingEngine.getCollateKernelDuration();
std::cout << __func__ << ": compactKernelDuration=" << compactDuration.count()
<< "ms, collateKernelDuration=" << collateDuration.count() << "ms" << std::endl;