From f3a4c6959781b120031a3652ac141efb38c0ed61 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Tue, 4 Nov 2025 00:46:07 -0400 Subject: [PATCH] StimBuff: DevAttSpec should be a sh_ptr, not a plain ref --- commonLibs/attachmentSupport/stimulusBuffer.cpp | 2 +- include/user/stimulusBuffer.h | 7 ++++--- stimBuffApis/livoxGen1/livoxGen1.cpp | 4 ++-- stimBuffApis/livoxGen1/pcloudStimulusBuffer.cpp | 6 ++++-- stimBuffApis/livoxGen1/pcloudStimulusBuffer.h | 3 +-- todo | 2 -- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/commonLibs/attachmentSupport/stimulusBuffer.cpp b/commonLibs/attachmentSupport/stimulusBuffer.cpp index 0828f1d..7f44ce4 100644 --- a/commonLibs/attachmentSupport/stimulusBuffer.cpp +++ b/commonLibs/attachmentSupport/stimulusBuffer.cpp @@ -36,7 +36,7 @@ void StimulusBuffer::stop() bridge.waitForAsyncOperationCompleteOrIoServiceStopped(); std::cout << __func__ << ": Stopped stimulus buffer for device " - << deviceAttachmentSpec.deviceSelector << std::endl; + << deviceAttachmentSpec->deviceSelector << std::endl; // After delay, cancel timer and perform cleanup timer.cancel(); diff --git a/include/user/stimulusBuffer.h b/include/user/stimulusBuffer.h index af75399..ddd37ad 100644 --- a/include/user/stimulusBuffer.h +++ b/include/user/stimulusBuffer.h @@ -48,7 +48,8 @@ public: public: explicit StimulusBuffer( - const device::DeviceAttachmentSpec& deviceAttachmentSpec, + const std::shared_ptr + &deviceAttachmentSpec, size_t nSlots, const SpMcRingBuffer::InputEngineConstraints& ringBufferConstraints, boost::asio::io_service& ioService) @@ -70,7 +71,7 @@ public: virtual void start() { std::cout << __func__ << ": Starting stimulus buffer for device " - << deviceAttachmentSpec.deviceSelector << std::endl; + << deviceAttachmentSpec->deviceSelector << std::endl; shouldContinue.store(true); scheduleNextTimeout(); @@ -91,7 +92,7 @@ private: void onTimeout(const boost::system::error_code& error); public: - device::DeviceAttachmentSpec deviceAttachmentSpec; + std::shared_ptr deviceAttachmentSpec; std::vector frames_; protected: diff --git a/stimBuffApis/livoxGen1/livoxGen1.cpp b/stimBuffApis/livoxGen1/livoxGen1.cpp index 08e7284..44c6310 100644 --- a/stimBuffApis/livoxGen1/livoxGen1.cpp +++ b/stimBuffApis/livoxGen1/livoxGen1.cpp @@ -37,7 +37,7 @@ getStimBuff(const std::shared_ptr& spec) for (const auto& stimBuff : attachedStimBuffs) { // Compare device selectors to find matching buffer - if (stimBuff->deviceAttachmentSpec.deviceSelector + if (stimBuff->deviceAttachmentSpec->deviceSelector == spec->deviceSelector) { return stimBuff; @@ -197,7 +197,7 @@ public: StimulusBuffer::PcloudFormatDesc formatDesc; formatDesc.format = StimulusBuffer::PcloudFormatDesc::Format::XYZI; auto pcloudStimBuff = std::make_shared( - *context->spec, context->deviceTmp, formatDesc, histbuffMs, 30); + context->spec, context->deviceTmp, formatDesc, histbuffMs, 30); context->stimBuff = pcloudStimBuff; context->deviceTmp->nAttachedStimBuffs++; diff --git a/stimBuffApis/livoxGen1/pcloudStimulusBuffer.cpp b/stimBuffApis/livoxGen1/pcloudStimulusBuffer.cpp index 2ce24ab..2c50c79 100644 --- a/stimBuffApis/livoxGen1/pcloudStimulusBuffer.cpp +++ b/stimBuffApis/livoxGen1/pcloudStimulusBuffer.cpp @@ -9,12 +9,14 @@ namespace smo { namespace stim_buff { +extern const SmoCallbacks* smoHooksPtr; + // OpenCL kernels are used to collate and produce our StimFrames. static SpMcRingBuffer::InputEngineConstraints openClInputConstraints( static_cast(sysconf(_SC_PAGE_SIZE)), sizeof(void *)); PcloudStimulusBuffer::PcloudStimulusBuffer( - const device::DeviceAttachmentSpec& deviceAttachmentSpec, + const std::shared_ptr &deviceAttachmentSpec, std::shared_ptr &device, const PcloudFormatDesc& formatDesc, int histbuffMs, @@ -24,7 +26,7 @@ PcloudStimulusBuffer::PcloudStimulusBuffer( static_cast(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS), openClInputConstraints, device->componentThread->getIoService()), -deviceAttachmentSpec(deviceAttachmentSpec), device(device), +device(device), formatDesc(formatDesc), stagingBuffer( StagingBuffer::InputEngineConstraints::ioUringConstraints, OpenClConstraints(), nDgramsPerStagingBufferFrame), diff --git a/stimBuffApis/livoxGen1/pcloudStimulusBuffer.h b/stimBuffApis/livoxGen1/pcloudStimulusBuffer.h index a64fff1..f429419 100644 --- a/stimBuffApis/livoxGen1/pcloudStimulusBuffer.h +++ b/stimBuffApis/livoxGen1/pcloudStimulusBuffer.h @@ -26,7 +26,7 @@ class PcloudStimulusBuffer { public: explicit PcloudStimulusBuffer( - const device::DeviceAttachmentSpec& deviceAttachmentSpec, + const std::shared_ptr &deviceAttachmentSpec, std::shared_ptr &device, const PcloudFormatDesc& formatDesc, int histbuffMs, @@ -55,7 +55,6 @@ public: void assembleAndProduceStimulusFrameReq( smo::Callback callback); - device::DeviceAttachmentSpec deviceAttachmentSpec; std::shared_ptr device; PcloudFormatDesc formatDesc; StagingBuffer stagingBuffer; diff --git a/todo b/todo index 6c7aefd..fb670c4 100644 --- a/todo +++ b/todo @@ -35,8 +35,6 @@ * We can use asynchronous bridging to ensure that asynchronous events are executed in the meantime while we wait for the sync timeout to complete. -* StimulusBuffer should take a sh_ptr and not - a DeviceAttachmentSpec&. * UdpCommandDemuxer::registerUdpCommandHandler should accept a pointer to the io_context of the thread it should post its callbacks to, and then post callbacks to those io_contexts when UDP cmd responses