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 <config.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <algorithm>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/asio/deadline_timer.hpp>
|
#include <boost/asio/deadline_timer.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
@@ -51,6 +52,21 @@ bool StimulusProducer::hasBufferWithQualeIfaceApi(
|
|||||||
return false;
|
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()
|
void StimulusProducer::stop()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ public:
|
|||||||
const std::shared_ptr<device::DeviceAttachmentSpec>
|
const std::shared_ptr<device::DeviceAttachmentSpec>
|
||||||
&deviceAttachmentSpec) = 0;
|
&deviceAttachmentSpec) = 0;
|
||||||
|
|
||||||
|
virtual void destroyAttachedStimulusBuffer(
|
||||||
|
const std::shared_ptr<StimulusBuffer>& buffer);
|
||||||
|
|
||||||
// Check if any attached buffer has the specified qualeIfaceApi
|
// Check if any attached buffer has the specified qualeIfaceApi
|
||||||
bool hasBufferWithQualeIfaceApi(const std::string& qualeIfaceApi) const;
|
bool hasBufferWithQualeIfaceApi(const std::string& qualeIfaceApi) const;
|
||||||
|
|
||||||
|
|||||||
@@ -463,22 +463,7 @@ public:
|
|||||||
auto& stimProducer = dynamic_cast<PcloudStimulusProducer&>(
|
auto& stimProducer = dynamic_cast<PcloudStimulusProducer&>(
|
||||||
context->stimBuffer->parent);
|
context->stimBuffer->parent);
|
||||||
|
|
||||||
auto it = std::find(
|
stimProducer.destroyAttachedStimulusBuffer(context->stimBuffer);
|
||||||
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(); }
|
|
||||||
|
|
||||||
// Check if StimProducer has other buffers
|
// Check if StimProducer has other buffers
|
||||||
if (!stimProducer.attachedStimulusBuffers.empty())
|
if (!stimProducer.attachedStimulusBuffers.empty())
|
||||||
|
|||||||
@@ -205,6 +205,23 @@ PcloudStimulusProducer::getAttachedStimulusBuffer(
|
|||||||
return nullptr;
|
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>
|
std::shared_ptr<StimulusBuffer>
|
||||||
PcloudStimulusProducer::getOrCreateAttachedStimulusBuffer(
|
PcloudStimulusProducer::getOrCreateAttachedStimulusBuffer(
|
||||||
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec
|
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec
|
||||||
|
|||||||
@@ -70,6 +70,9 @@ public:
|
|||||||
const std::shared_ptr<device::DeviceAttachmentSpec>& spec)
|
const std::shared_ptr<device::DeviceAttachmentSpec>& spec)
|
||||||
const override;
|
const override;
|
||||||
|
|
||||||
|
void destroyAttachedStimulusBuffer(
|
||||||
|
const std::shared_ptr<StimulusBuffer>& buffer) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void stimFrameProductionTimesliceInd() override;
|
void stimFrameProductionTimesliceInd() override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user