1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Convolution: Fix issue where old convolution engines were sometimes used after calling prepare

The startThread/stopThread calls were moved to prevent a thread
sanitizer warning about a race on the vtable of Impl.
This commit is contained in:
reuk 2020-07-10 20:02:50 +01:00
parent 3de4fab219
commit 5ab6042c04
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -77,14 +77,7 @@ class BackgroundMessageQueue : private Thread
public:
explicit BackgroundMessageQueue (int entries)
: Thread ("Convolution background loader"), queue (entries)
{
startThread();
}
~BackgroundMessageQueue() override
{
stopThread (-1);
}
{}
using IncomingCommand = FixedSizeFunction<400, void()>;
@ -93,6 +86,9 @@ public:
// This function is only safe to call from a single thread at a time.
bool push (IncomingCommand& command) { return queue.push (command); }
using Thread::startThread;
using Thread::stopThread;
private:
void run() override
{
@ -119,9 +115,14 @@ ConvolutionMessageQueue::ConvolutionMessageQueue()
ConvolutionMessageQueue::ConvolutionMessageQueue (int entries)
: pimpl (std::make_unique<Impl> (entries))
{}
{
pimpl->startThread();
}
ConvolutionMessageQueue::~ConvolutionMessageQueue() noexcept = default;
ConvolutionMessageQueue::~ConvolutionMessageQueue() noexcept
{
pimpl->stopThread (-1);
}
ConvolutionMessageQueue::ConvolutionMessageQueue (ConvolutionMessageQueue&&) noexcept = default;
ConvolutionMessageQueue& ConvolutionMessageQueue::operator= (ConvolutionMessageQueue&&) noexcept = default;
@ -1016,7 +1017,8 @@ public:
{
mixer.prepare (spec);
engineQueue->prepare (spec);
installPendingEngine();
currentEngine = engineQueue->getEngine();
previousEngine = nullptr;
jassert (currentEngine != nullptr);
}