StimProducer: add destroyAttachedStimulusBuffer virtual method
Implemented in base class and in derived class PcloudStimulusProducer.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <config.h>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <algorithm>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
@@ -51,6 +52,21 @@ bool StimulusProducer::hasBufferWithQualeIfaceApi(
|
||||
return false;
|
||||
}
|
||||
|
||||
void StimulusProducer::destroyAttachedStimulusBuffer(
|
||||
const std::shared_ptr<StimulusBuffer>& buffer)
|
||||
{
|
||||
if (!buffer) { return; }
|
||||
|
||||
auto it = std::find(
|
||||
attachedStimulusBuffers.begin(),
|
||||
attachedStimulusBuffers.end(),
|
||||
buffer);
|
||||
|
||||
if (it != attachedStimulusBuffers.end()) {
|
||||
attachedStimulusBuffers.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void StimulusProducer::stop()
|
||||
{
|
||||
{
|
||||
|
||||
@@ -76,6 +76,9 @@ public:
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>
|
||||
&deviceAttachmentSpec) = 0;
|
||||
|
||||
virtual void destroyAttachedStimulusBuffer(
|
||||
const std::shared_ptr<StimulusBuffer>& buffer);
|
||||
|
||||
// Check if any attached buffer has the specified qualeIfaceApi
|
||||
bool hasBufferWithQualeIfaceApi(const std::string& qualeIfaceApi) const;
|
||||
|
||||
|
||||
@@ -463,22 +463,7 @@ public:
|
||||
auto& stimProducer = dynamic_cast<PcloudStimulusProducer&>(
|
||||
context->stimBuffer->parent);
|
||||
|
||||
auto it = std::find(
|
||||
stimProducer.attachedStimulusBuffers.begin(),
|
||||
stimProducer.attachedStimulusBuffers.end(),
|
||||
context->stimBuffer);
|
||||
if (it != stimProducer.attachedStimulusBuffers.end())
|
||||
{
|
||||
stimProducer.attachedStimulusBuffers.erase(it);
|
||||
}
|
||||
|
||||
// Clear specialized buffer members if they match
|
||||
if (stimProducer.meshStimulusBuffer == context->stimBuffer)
|
||||
{ stimProducer.meshStimulusBuffer.reset(); }
|
||||
if (stimProducer.intensityStimulusBuffer == context->stimBuffer)
|
||||
{ stimProducer.intensityStimulusBuffer.reset(); }
|
||||
if (stimProducer.ambienceStimulusBuffer == context->stimBuffer)
|
||||
{ stimProducer.ambienceStimulusBuffer.reset(); }
|
||||
stimProducer.destroyAttachedStimulusBuffer(context->stimBuffer);
|
||||
|
||||
// Check if StimProducer has other buffers
|
||||
if (!stimProducer.attachedStimulusBuffers.empty())
|
||||
|
||||
@@ -205,6 +205,23 @@ PcloudStimulusProducer::getAttachedStimulusBuffer(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PcloudStimulusProducer::destroyAttachedStimulusBuffer(
|
||||
const std::shared_ptr<StimulusBuffer>& buffer)
|
||||
{
|
||||
if (!buffer) { return; }
|
||||
|
||||
// Clear specialized buffer pointers if they match
|
||||
if (meshStimulusBuffer == buffer)
|
||||
{ meshStimulusBuffer.reset(); }
|
||||
if (intensityStimulusBuffer == buffer)
|
||||
{ intensityStimulusBuffer.reset(); }
|
||||
if (ambienceStimulusBuffer == buffer)
|
||||
{ ambienceStimulusBuffer.reset(); }
|
||||
|
||||
// Call base class implementation to remove from attachedStimulusBuffers
|
||||
StimulusProducer::destroyAttachedStimulusBuffer(buffer);
|
||||
}
|
||||
|
||||
std::shared_ptr<StimulusBuffer>
|
||||
PcloudStimulusProducer::getOrCreateAttachedStimulusBuffer(
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec
|
||||
|
||||
@@ -70,6 +70,9 @@ public:
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>& spec)
|
||||
const override;
|
||||
|
||||
void destroyAttachedStimulusBuffer(
|
||||
const std::shared_ptr<StimulusBuffer>& buffer) override;
|
||||
|
||||
protected:
|
||||
void stimFrameProductionTimesliceInd() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user