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

AudioProcessorGraph: Fix race condition when destroying AudioProcessorGraph on a background thread

This commit is contained in:
reuk 2023-04-13 18:01:01 +01:00
parent 8fc76c4376
commit dcef8b88b2
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -1677,17 +1677,11 @@ bool AudioProcessorGraph::Connection::operator< (const Connection& other) const
}
//==============================================================================
class AudioProcessorGraph::Pimpl : public AsyncUpdater
class AudioProcessorGraph::Pimpl
{
public:
explicit Pimpl (AudioProcessorGraph& o) : owner (&o) {}
~Pimpl() override
{
cancelPendingUpdate();
clear (UpdateKind::sync);
}
const auto& getNodes() const { return nodes.getNodes(); }
void clear (UpdateKind updateKind)
@ -1840,7 +1834,7 @@ public:
if (updateKind == UpdateKind::sync && MessageManager::getInstance()->isThisTheMessageThread())
handleAsyncUpdate();
else
triggerAsyncUpdate();
updater.triggerAsyncUpdate();
}
void reset()
@ -1902,7 +1896,7 @@ private:
rebuild (updateKind);
}
void handleAsyncUpdate() override
void handleAsyncUpdate()
{
if (const auto newSettings = nodeStates.applySettings (nodes))
{
@ -1933,6 +1927,7 @@ private:
RenderSequenceExchange renderSequenceExchange;
NodeID lastNodeID;
std::optional<RenderSequenceSignature> lastBuiltSequence;
LockingAsyncUpdater updater { [this] { handleAsyncUpdate(); } };
};
//==============================================================================