Proxies must not store thread local data - fix FrameLib_ToHost by passing the allocator when needed
This commit is contained in:
@@ -11,8 +11,8 @@ class FrameLib_MaxClass_ToMax : public FrameLib_MaxClass_Expand<FrameLib_ToHost>
|
||||
{
|
||||
ToHostProxy(FrameLib_MaxClass_ToMax *object) : mObject(object){}
|
||||
|
||||
void sendToHost(unsigned long index, unsigned long stream, const double *values, unsigned long N) override;
|
||||
void sendToHost(unsigned long index, unsigned long stream, const FrameLib_Parameters::Serial *serial) override;
|
||||
void sendToHost(FrameLib_DSP::Allocator &allocator, unsigned long index, unsigned long stream, const double *values, unsigned long N) override;
|
||||
void sendToHost(FrameLib_DSP::Allocator &allocator, unsigned long index, unsigned long stream, const FrameLib_Parameters::Serial *serial) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -46,12 +46,12 @@ private:
|
||||
|
||||
// Proxy Class
|
||||
|
||||
void FrameLib_MaxClass_ToMax::ToHostProxy::sendToHost(unsigned long index, unsigned long stream, const double *values, unsigned long N)
|
||||
void FrameLib_MaxClass_ToMax::ToHostProxy::sendToHost(FrameLib_DSP::Allocator &allocator, unsigned long index, unsigned long stream, const double *values, unsigned long N)
|
||||
{
|
||||
method outletMethod = (method) &FrameLib_MaxClass_ToMax::toOutletExternal;
|
||||
|
||||
N = limitSize(N + 1);
|
||||
t_atom *output = alloc<t_atom>(N);
|
||||
t_atom *output = allocator.allocate<t_atom>(N);
|
||||
|
||||
if (output)
|
||||
{
|
||||
@@ -62,11 +62,11 @@ void FrameLib_MaxClass_ToMax::ToHostProxy::sendToHost(unsigned long index, unsig
|
||||
|
||||
schedule_delay(mObject, outletMethod, 0, nullptr, static_cast<short>(N), output);
|
||||
|
||||
dealloc(output);
|
||||
allocator.deallocate(output);
|
||||
}
|
||||
}
|
||||
|
||||
void FrameLib_MaxClass_ToMax::ToHostProxy::sendToHost(unsigned long index, unsigned long stream, const FrameLib_Parameters::Serial *serial)
|
||||
void FrameLib_MaxClass_ToMax::ToHostProxy::sendToHost(FrameLib_DSP::Allocator &allocator, unsigned long index, unsigned long stream, const FrameLib_Parameters::Serial *serial)
|
||||
{
|
||||
method outletMethod = (method) &FrameLib_MaxClass_ToMax::toOutletExternal;
|
||||
|
||||
@@ -84,7 +84,7 @@ void FrameLib_MaxClass_ToMax::ToHostProxy::sendToHost(unsigned long index, unsig
|
||||
}
|
||||
|
||||
maxSize = std::max(limitSize(maxSize + 1), 2UL);
|
||||
t_atom *output = alloc<t_atom>(maxSize);
|
||||
t_atom *output = allocator.allocate<t_atom>(maxSize);
|
||||
|
||||
if (!output)
|
||||
return;
|
||||
@@ -117,7 +117,7 @@ void FrameLib_MaxClass_ToMax::ToHostProxy::sendToHost(unsigned long index, unsig
|
||||
schedule_delay(mObject, outletMethod, 0, tag, static_cast<short>(size), output);
|
||||
}
|
||||
|
||||
dealloc(output);
|
||||
allocator.deallocate(output);
|
||||
}
|
||||
|
||||
// Max Class
|
||||
|
||||
@@ -12,10 +12,7 @@ FrameLib_ToHost::FrameLib_ToHost(FrameLib_Context context, FrameLib_Parameters::
|
||||
setInputMode(0, false, true, false, kFrameAny);
|
||||
|
||||
if (mProxy)
|
||||
{
|
||||
mID = mProxy->registerObject(this, mStreamOwner, mStream);
|
||||
mProxy->mObject = this;
|
||||
}
|
||||
}
|
||||
|
||||
FrameLib_ToHost::~FrameLib_ToHost()
|
||||
@@ -62,18 +59,20 @@ void FrameLib_ToHost::process()
|
||||
{
|
||||
if (mProxy)
|
||||
{
|
||||
Allocator allocator(*this);
|
||||
|
||||
if (getInputCurrentType(0) == kFrameNormal)
|
||||
{
|
||||
unsigned long sizeIn;
|
||||
const double *input = getInput(0, &sizeIn);
|
||||
|
||||
mProxy->sendToHost(mID, mStream, input, sizeIn);
|
||||
mProxy->sendToHost(allocator, mID, mStream, input, sizeIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
const FrameLib_Parameters::Serial *input = getInput(0);
|
||||
|
||||
mProxy->sendToHost(mID, mStream, input);
|
||||
mProxy->sendToHost(allocator, mID, mStream, input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,19 +16,10 @@ public:
|
||||
{
|
||||
friend FrameLib_ToHost;
|
||||
|
||||
Proxy() : mObject(nullptr) {}
|
||||
Proxy() {}
|
||||
|
||||
virtual void sendToHost(unsigned long index, unsigned long stream, const double *values, unsigned long N) = 0;
|
||||
virtual void sendToHost(unsigned long index, unsigned long stream, const FrameLib_Parameters::Serial *serial)= 0;
|
||||
|
||||
// These methods should only be used to allocate temporary memory in the overrides of the output methods
|
||||
|
||||
template <class T> T *alloc(unsigned long N) { return mObject->alloc<T>(N); }
|
||||
template <class T> void dealloc(T *& ptr) { return mObject->dealloc(ptr); }
|
||||
|
||||
private:
|
||||
|
||||
FrameLib_ToHost *mObject;
|
||||
virtual void sendToHost(Allocator& allocator, unsigned long index, unsigned long stream, const double *values, unsigned long N) = 0;
|
||||
virtual void sendToHost(Allocator& allocator, unsigned long index, unsigned long stream, const FrameLib_Parameters::Serial *serial)= 0;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user