mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Ensure that AudioUnitUninitialize is called on the message thread when destroying an AudioUnitPluginInstance
This commit is contained in:
parent
5098232062
commit
7eb80b815c
1 changed files with 23 additions and 18 deletions
|
|
@ -340,50 +340,55 @@ public:
|
|||
jassert (AudioUnitFormatHelpers::insideCallback.get() == 0);
|
||||
#endif
|
||||
|
||||
#if JUCE_MAC
|
||||
if (eventListenerRef != 0)
|
||||
{
|
||||
AUListenerDispose (eventListenerRef);
|
||||
eventListenerRef = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (audioUnit != nullptr)
|
||||
{
|
||||
if (prepared)
|
||||
releaseResources();
|
||||
|
||||
struct AUDeleter : public CallbackMessage
|
||||
{
|
||||
AUDeleter (AudioComponentInstance& inInstance, WaitableEvent& inEvent)
|
||||
AUDeleter (AudioUnitPluginInstance& inInstance, WaitableEvent& inEvent)
|
||||
: auInstance (inInstance), completionSignal (inEvent)
|
||||
{}
|
||||
|
||||
void messageCallback() override
|
||||
{
|
||||
AudioComponentInstanceDispose (auInstance);
|
||||
auInstance = nullptr;
|
||||
auInstance.cleanup();
|
||||
completionSignal.signal();
|
||||
}
|
||||
|
||||
AudioComponentInstance& auInstance;
|
||||
AudioUnitPluginInstance& auInstance;
|
||||
WaitableEvent& completionSignal;
|
||||
};
|
||||
|
||||
if (MessageManager::getInstance()->isThisTheMessageThread())
|
||||
{
|
||||
AudioComponentInstanceDispose (audioUnit);
|
||||
audioUnit = nullptr;
|
||||
cleanup();
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitableEvent completionEvent;
|
||||
(new AUDeleter (audioUnit, completionEvent))->post();
|
||||
(new AUDeleter (*this, completionEvent))->post();
|
||||
completionEvent.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// called from the destructer above
|
||||
void cleanup()
|
||||
{
|
||||
#if JUCE_MAC
|
||||
if (eventListenerRef != 0)
|
||||
{
|
||||
AUListenerDispose (eventListenerRef);
|
||||
eventListenerRef = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (prepared)
|
||||
releaseResources();
|
||||
|
||||
AudioComponentInstanceDispose (audioUnit);
|
||||
audioUnit = nullptr;
|
||||
}
|
||||
|
||||
bool initialise (double rate, int blockSize)
|
||||
{
|
||||
updateNumChannels();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue