PcloudStimBuff: Add skeleton daemon; frame rate limiting

Basic implementation of the stimbuff mechanism's frame rate
limiting behaviour.
This commit is contained in:
2025-10-31 12:22:07 -04:00
parent 7994c2f6e2
commit f32a472c5d
2 changed files with 127 additions and 8 deletions
+18 -7
View File
@@ -1,6 +1,10 @@
#ifndef _LIVOX_GEN1_PCLOUD_STIMULUS_BUFFER_H
#define _LIVOX_GEN1_PCLOUD_STIMULUS_BUFFER_H
#include <config.h>
#include <atomic>
#include <boost/asio/deadline_timer.hpp>
#include <spinLock.h>
#include <user/stimulusBuffer.h>
#include <user/stimFrame.h>
#include <livoxProto1/device.h>
@@ -26,13 +30,7 @@ public:
const device::DeviceAttachmentSpec& deviceAttachmentSpec,
std::shared_ptr<livoxProto1::Device> &device,
const PcloudFormatDesc& formatDesc,
size_t nDgramsPerStagingBufferFrame)
: StimulusBuffer(deviceAttachmentSpec),
deviceAttachmentSpec(deviceAttachmentSpec), device(device),
formatDesc(formatDesc), stagingBuffer(
StagingBuffer::InputEngineConstraints::ioUringConstraints,
OpenClConstraints(), nDgramsPerStagingBufferFrame)
{}
size_t nDgramsPerStagingBufferFrame);
~PcloudStimulusBuffer() = default;
@@ -42,12 +40,25 @@ public:
PcloudStimulusBuffer(PcloudStimulusBuffer&&) = default;
PcloudStimulusBuffer& operator=(PcloudStimulusBuffer&&) = default;
// Control methods
void start();
void stop();
public:
device::DeviceAttachmentSpec deviceAttachmentSpec;
std::shared_ptr<livoxProto1::Device> device;
PcloudFormatDesc formatDesc;
StagingBuffer stagingBuffer;
IoUringAssemblyEngine ioUringAssemblyEngine;
private:
std::atomic<bool> shouldContinue;
boost::asio::deadline_timer timer;
SpinLock frameAssemblyRateLimiter;
private:
void scheduleNextTimeout(int delayMs = CONFIG_STIMBUFF_FRAME_PERIOD_MS);
void onTimeout(const boost::system::error_code& error);
};
} // namespace stim_buff