#include #include #include #include #include #include #include "pcloudStimulusBuffer.h" 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 std::shared_ptr &deviceAttachmentSpec, std::shared_ptr &device, const PcloudFormatDesc& formatDesc, int histbuffMs, size_t nDgramsPerStagingBufferFrame) : StimulusBuffer( deviceAttachmentSpec, static_cast(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS), openClInputConstraints, device->componentThread->getIoService()), device(device), formatDesc(formatDesc), stagingBuffer( StagingBuffer::InputEngineConstraints::ioUringConstraints, OpenClConstraints(), nDgramsPerStagingBufferFrame), ioUringAssemblyEngine(*this) { } void PcloudStimulusBuffer::start() { // Call ioUringAssemblyEngine setup() as the final step // ioUringAssemblyEngine.setup(); // Call base class start() as the final step StimulusBuffer::start(); } void PcloudStimulusBuffer::stop() { // Call base class stop() as the first step StimulusBuffer::stop(); // Call ioUringAssemblyEngine stop() as the final step // ioUringAssemblyEngine.finalize(); } void PcloudStimulusBuffer::stimFrameProductionTimesliceInd() { // Release the spinlock for now frameAssemblyRateLimiter.release(); } class PcloudStimulusBuffer::AssembleAndProduceStimulusFrameReq : public smo::PostedAsynchronousContinuation< assembleAndProduceStimulusFrameReqCbFn> { private: PcloudStimulusBuffer& stimBuff; public: AssembleAndProduceStimulusFrameReq( PcloudStimulusBuffer& buffer, Callback callback) : PostedAsynchronousContinuation( buffer.device->componentThread, std::move(callback)), stimBuff(buffer) {} void callOriginalCallback() { stimBuff.frameAssemblyRateLimiter.release(); callOriginalCb(static_cast(0)); } void callOriginalCallbackWithFailure() { stimBuff.frameAssemblyRateLimiter.release(); callOriginalCb(static_cast(0)); } }; void PcloudStimulusBuffer::assembleAndProduceStimulusFrameReq( smo::Callback callback) { // Wireframe implementation - do nothing for now (void)callback; } } // namespace stim_buff } // namespace smo