Messages that have side effects on buffers need to make sure they do the nrt->rt buffer swap thing

nix
Owen Green 6 years ago
parent 26b341f109
commit 0d99d71246

@ -24,6 +24,26 @@ class FluidSCWrapper;
namespace impl { namespace impl {
template <size_t N, typename T>
struct AssignBuffer
{
void operator()(const typename BufferT::type &p, World *w)
{
if (auto b = static_cast<SCBufferAdaptor *>(p.get()))
b->assignToRT(w);
}
};
template <size_t N, typename T>
struct CleanUpBuffer
{
void operator()(const typename BufferT::type &p)
{
if (auto b = static_cast<SCBufferAdaptor *>(p.get())) b->cleanUp();
}
};
// Iterate over kr/ir inputs via callbacks from params object // Iterate over kr/ir inputs via callbacks from params object
struct FloatControlsIter struct FloatControlsIter
{ {
@ -295,33 +315,17 @@ private:
bool exchangeBuffers(World *world) bool exchangeBuffers(World *world)
{ {
mParams.template forEachParamType<BufferT, AssignBuffer>(world); mParams.template forEachParamType<BufferT, impl::AssignBuffer>(world);
return true; return true;
} }
bool tidyUp(World *) bool tidyUp(World *)
{ {
mParams.template forEachParamType<BufferT, CleanUpBuffer>(); mParams.template forEachParamType<BufferT, impl::CleanUpBuffer>();
return true; return true;
} }
template <size_t N, typename T>
struct AssignBuffer
{
void operator()(const typename BufferT::type &p, World *w)
{
if (auto b = static_cast<SCBufferAdaptor *>(p.get())) b->assignToRT(w);
}
};
template <size_t N, typename T>
struct CleanUpBuffer
{
void operator()(const typename BufferT::type &p)
{
if (auto b = static_cast<SCBufferAdaptor *>(p.get())) b->cleanUp();
}
};
FloatControlsIter mControlsIterator; FloatControlsIter mControlsIterator;
FifoMsg mFifoMsg; FifoMsg mFifoMsg;
@ -627,9 +631,10 @@ class FluidSCWrapper : public impl::FluidSCWrapperBase<C>
} }
return true; return true;
}, },
[](World*, void* data) //RT thread: response [](World* world, void* data) //RT thread: response
{ {
MessageData* m = static_cast<MessageData*>(data); MessageData* m = static_cast<MessageData*>(data);
MessageDescriptor::template forEachArg<typename BufferT::type,impl::AssignBuffer>(m->args, world);
messageOutput(m->wrapper,m->name,m->result); messageOutput(m->wrapper,m->name,m->result);
return true; return true;
} }

Loading…
Cancel
Save