StimBuff: DevAttSpec should be a sh_ptr, not a plain ref

This commit is contained in:
2025-11-04 00:46:07 -04:00
parent 032e9ef8d5
commit f3a4c69597
6 changed files with 12 additions and 12 deletions
@@ -36,7 +36,7 @@ void StimulusBuffer::stop()
bridge.waitForAsyncOperationCompleteOrIoServiceStopped(); bridge.waitForAsyncOperationCompleteOrIoServiceStopped();
std::cout << __func__ << ": Stopped stimulus buffer for device " std::cout << __func__ << ": Stopped stimulus buffer for device "
<< deviceAttachmentSpec.deviceSelector << std::endl; << deviceAttachmentSpec->deviceSelector << std::endl;
// After delay, cancel timer and perform cleanup // After delay, cancel timer and perform cleanup
timer.cancel(); timer.cancel();
+4 -3
View File
@@ -48,7 +48,8 @@ public:
public: public:
explicit StimulusBuffer( explicit StimulusBuffer(
const device::DeviceAttachmentSpec& deviceAttachmentSpec, const std::shared_ptr<device::DeviceAttachmentSpec>
&deviceAttachmentSpec,
size_t nSlots, size_t nSlots,
const SpMcRingBuffer::InputEngineConstraints& ringBufferConstraints, const SpMcRingBuffer::InputEngineConstraints& ringBufferConstraints,
boost::asio::io_service& ioService) boost::asio::io_service& ioService)
@@ -70,7 +71,7 @@ public:
virtual void start() virtual void start()
{ {
std::cout << __func__ << ": Starting stimulus buffer for device " std::cout << __func__ << ": Starting stimulus buffer for device "
<< deviceAttachmentSpec.deviceSelector << std::endl; << deviceAttachmentSpec->deviceSelector << std::endl;
shouldContinue.store(true); shouldContinue.store(true);
scheduleNextTimeout(); scheduleNextTimeout();
@@ -91,7 +92,7 @@ private:
void onTimeout(const boost::system::error_code& error); void onTimeout(const boost::system::error_code& error);
public: public:
device::DeviceAttachmentSpec deviceAttachmentSpec; std::shared_ptr<device::DeviceAttachmentSpec> deviceAttachmentSpec;
std::vector<StimFrame> frames_; std::vector<StimFrame> frames_;
protected: protected:
+2 -2
View File
@@ -37,7 +37,7 @@ getStimBuff(const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
for (const auto& stimBuff : attachedStimBuffs) for (const auto& stimBuff : attachedStimBuffs)
{ {
// Compare device selectors to find matching buffer // Compare device selectors to find matching buffer
if (stimBuff->deviceAttachmentSpec.deviceSelector if (stimBuff->deviceAttachmentSpec->deviceSelector
== spec->deviceSelector) == spec->deviceSelector)
{ {
return stimBuff; return stimBuff;
@@ -197,7 +197,7 @@ public:
StimulusBuffer::PcloudFormatDesc formatDesc; StimulusBuffer::PcloudFormatDesc formatDesc;
formatDesc.format = StimulusBuffer::PcloudFormatDesc::Format::XYZI; formatDesc.format = StimulusBuffer::PcloudFormatDesc::Format::XYZI;
auto pcloudStimBuff = std::make_shared<PcloudStimulusBuffer>( auto pcloudStimBuff = std::make_shared<PcloudStimulusBuffer>(
*context->spec, context->deviceTmp, formatDesc, histbuffMs, 30); context->spec, context->deviceTmp, formatDesc, histbuffMs, 30);
context->stimBuff = pcloudStimBuff; context->stimBuff = pcloudStimBuff;
context->deviceTmp->nAttachedStimBuffs++; context->deviceTmp->nAttachedStimBuffs++;
@@ -9,12 +9,14 @@
namespace smo { namespace smo {
namespace stim_buff { namespace stim_buff {
extern const SmoCallbacks* smoHooksPtr;
// OpenCL kernels are used to collate and produce our StimFrames. // OpenCL kernels are used to collate and produce our StimFrames.
static SpMcRingBuffer::InputEngineConstraints openClInputConstraints( static SpMcRingBuffer::InputEngineConstraints openClInputConstraints(
static_cast<size_t>(sysconf(_SC_PAGE_SIZE)), sizeof(void *)); static_cast<size_t>(sysconf(_SC_PAGE_SIZE)), sizeof(void *));
PcloudStimulusBuffer::PcloudStimulusBuffer( PcloudStimulusBuffer::PcloudStimulusBuffer(
const device::DeviceAttachmentSpec& deviceAttachmentSpec, const std::shared_ptr<device::DeviceAttachmentSpec> &deviceAttachmentSpec,
std::shared_ptr<livoxProto1::Device> &device, std::shared_ptr<livoxProto1::Device> &device,
const PcloudFormatDesc& formatDesc, const PcloudFormatDesc& formatDesc,
int histbuffMs, int histbuffMs,
@@ -24,7 +26,7 @@ PcloudStimulusBuffer::PcloudStimulusBuffer(
static_cast<size_t>(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS), static_cast<size_t>(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS),
openClInputConstraints, openClInputConstraints,
device->componentThread->getIoService()), device->componentThread->getIoService()),
deviceAttachmentSpec(deviceAttachmentSpec), device(device), device(device),
formatDesc(formatDesc), stagingBuffer( formatDesc(formatDesc), stagingBuffer(
StagingBuffer::InputEngineConstraints::ioUringConstraints, StagingBuffer::InputEngineConstraints::ioUringConstraints,
OpenClConstraints(), nDgramsPerStagingBufferFrame), OpenClConstraints(), nDgramsPerStagingBufferFrame),
@@ -26,7 +26,7 @@ class PcloudStimulusBuffer
{ {
public: public:
explicit PcloudStimulusBuffer( explicit PcloudStimulusBuffer(
const device::DeviceAttachmentSpec& deviceAttachmentSpec, const std::shared_ptr<device::DeviceAttachmentSpec> &deviceAttachmentSpec,
std::shared_ptr<livoxProto1::Device> &device, std::shared_ptr<livoxProto1::Device> &device,
const PcloudFormatDesc& formatDesc, const PcloudFormatDesc& formatDesc,
int histbuffMs, int histbuffMs,
@@ -55,7 +55,6 @@ public:
void assembleAndProduceStimulusFrameReq( void assembleAndProduceStimulusFrameReq(
smo::Callback<assembleAndProduceStimulusFrameReqCbFn> callback); smo::Callback<assembleAndProduceStimulusFrameReqCbFn> callback);
device::DeviceAttachmentSpec deviceAttachmentSpec;
std::shared_ptr<livoxProto1::Device> device; std::shared_ptr<livoxProto1::Device> device;
PcloudFormatDesc formatDesc; PcloudFormatDesc formatDesc;
StagingBuffer stagingBuffer; StagingBuffer stagingBuffer;
-2
View File
@@ -35,8 +35,6 @@
* We can use asynchronous bridging to ensure that asynchronous * We can use asynchronous bridging to ensure that asynchronous
events are executed in the meantime while we wait for the sync events are executed in the meantime while we wait for the sync
timeout to complete. timeout to complete.
* StimulusBuffer should take a sh_ptr<DeviceAttachmentSpec> and not
a DeviceAttachmentSpec&.
* UdpCommandDemuxer::registerUdpCommandHandler should accept a pointer * UdpCommandDemuxer::registerUdpCommandHandler should accept a pointer
to the io_context of the thread it should post its callbacks to, and 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 then post callbacks to those io_contexts when UDP cmd responses