| @@ -713,7 +713,7 @@ namespace AAXClasses | |||||
| if (isPrepared && pluginInstance != nullptr) | if (isPrepared && pluginInstance != nullptr) | ||||
| { | { | ||||
| isPrepared = false; | isPrepared = false; | ||||
| processingSidechainChange.set (0); | |||||
| processingSidechainChange = false; | |||||
| pluginInstance->releaseResources(); | pluginInstance->releaseResources(); | ||||
| } | } | ||||
| @@ -725,7 +725,7 @@ namespace AAXClasses | |||||
| { | { | ||||
| cancelPendingUpdate(); | cancelPendingUpdate(); | ||||
| check (Controller()->GetSampleRate (&sampleRate)); | check (Controller()->GetSampleRate (&sampleRate)); | ||||
| processingSidechainChange.set (0); | |||||
| processingSidechainChange = false; | |||||
| auto err = preparePlugin(); | auto err = preparePlugin(); | ||||
| if (err != AAX_SUCCESS) | if (err != AAX_SUCCESS) | ||||
| @@ -1103,8 +1103,8 @@ namespace AAXClasses | |||||
| case AAX_eNotificationEvent_SideChainBeingConnected: | case AAX_eNotificationEvent_SideChainBeingConnected: | ||||
| case AAX_eNotificationEvent_SideChainBeingDisconnected: | case AAX_eNotificationEvent_SideChainBeingDisconnected: | ||||
| { | { | ||||
| processingSidechainChange.set (1); | |||||
| sidechainDesired.set (type == AAX_eNotificationEvent_SideChainBeingConnected ? 1 : 0); | |||||
| processingSidechainChange = true; | |||||
| sidechainDesired = (type == AAX_eNotificationEvent_SideChainBeingConnected); | |||||
| updateSidechainState(); | updateSidechainState(); | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -1132,23 +1132,25 @@ namespace AAXClasses | |||||
| auto numOuts = pluginInstance->getTotalNumOutputChannels(); | auto numOuts = pluginInstance->getTotalNumOutputChannels(); | ||||
| auto numMeters = aaxMeters.size(); | auto numMeters = aaxMeters.size(); | ||||
| bool processWantsSidechain = (sideChainBufferIdx != -1); | |||||
| bool isSuspended = pluginInstance->isSuspended(); | |||||
| const ScopedLock sl (pluginInstance->getCallbackLock()); | |||||
| if (processingSidechainChange.get() == 0) | |||||
| bool isSuspended = [this, sideChainBufferIdx] | |||||
| { | { | ||||
| if (hasSidechain && canDisableSidechain && (sidechainDesired.get() != 0) != processWantsSidechain) | |||||
| if (processingSidechainChange) | |||||
| return true; | |||||
| bool processWantsSidechain = (sideChainBufferIdx != -1); | |||||
| if (hasSidechain && canDisableSidechain && (sidechainDesired != processWantsSidechain)) | |||||
| { | { | ||||
| isSuspended = true; | |||||
| sidechainDesired.set (processWantsSidechain ? 1 : 0); | |||||
| processingSidechainChange.set (1); | |||||
| sidechainDesired = processWantsSidechain; | |||||
| processingSidechainChange = true; | |||||
| triggerAsyncUpdate(); | triggerAsyncUpdate(); | ||||
| return true; | |||||
| } | } | ||||
| } | |||||
| else | |||||
| { | |||||
| isSuspended = true; | |||||
| } | |||||
| return pluginInstance->isSuspended(); | |||||
| }(); | |||||
| if (isSuspended) | if (isSuspended) | ||||
| { | { | ||||
| @@ -1422,8 +1424,6 @@ namespace AAXClasses | |||||
| } | } | ||||
| } | } | ||||
| const ScopedLock sl (pluginInstance->getCallbackLock()); | |||||
| if (bypass) | if (bypass) | ||||
| pluginInstance->processBlockBypassed (buffer, midiBuffer); | pluginInstance->processBlockBypassed (buffer, midiBuffer); | ||||
| else | else | ||||
| @@ -1632,7 +1632,7 @@ namespace AAXClasses | |||||
| if (hasSidechain) | if (hasSidechain) | ||||
| { | { | ||||
| sidechainDesired.set (1); | |||||
| sidechainDesired = true; | |||||
| auto disabledSidechainLayout = newLayout; | auto disabledSidechainLayout = newLayout; | ||||
| disabledSidechainLayout.inputBuses.getReference (1) = AudioChannelSet::disabled(); | disabledSidechainLayout.inputBuses.getReference (1) = AudioChannelSet::disabled(); | ||||
| @@ -1641,7 +1641,7 @@ namespace AAXClasses | |||||
| if (canDisableSidechain && ! lastSideChainState) | if (canDisableSidechain && ! lastSideChainState) | ||||
| { | { | ||||
| sidechainDesired.set (0); | |||||
| sidechainDesired = false; | |||||
| newLayout = disabledSidechainLayout; | newLayout = disabledSidechainLayout; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1765,15 +1765,15 @@ namespace AAXClasses | |||||
| //============================================================================== | //============================================================================== | ||||
| void updateSidechainState() | void updateSidechainState() | ||||
| { | { | ||||
| if (processingSidechainChange.get() == 0) | |||||
| if (! processingSidechainChange) | |||||
| return; | return; | ||||
| auto& audioProcessor = getPluginInstance(); | auto& audioProcessor = getPluginInstance(); | ||||
| bool sidechainActual = audioProcessor.getChannelCountOfBus (true, 1) > 0; | bool sidechainActual = audioProcessor.getChannelCountOfBus (true, 1) > 0; | ||||
| if (hasSidechain && canDisableSidechain && (sidechainDesired.get() != 0) != sidechainActual) | |||||
| if (hasSidechain && canDisableSidechain && sidechainDesired != sidechainActual) | |||||
| { | { | ||||
| lastSideChainState = (sidechainDesired.get() != 0); | |||||
| lastSideChainState = sidechainDesired; | |||||
| if (isPrepared) | if (isPrepared) | ||||
| { | { | ||||
| @@ -1789,7 +1789,7 @@ namespace AAXClasses | |||||
| isPrepared = true; | isPrepared = true; | ||||
| } | } | ||||
| processingSidechainChange.set (0); | |||||
| processingSidechainChange = false; | |||||
| } | } | ||||
| void handleAsyncUpdate() override | void handleAsyncUpdate() override | ||||
| @@ -1960,7 +1960,7 @@ namespace AAXClasses | |||||
| int lastBufferSize = 1024, maxBufferSize = 1024; | int lastBufferSize = 1024, maxBufferSize = 1024; | ||||
| bool hasSidechain = false, canDisableSidechain = false, lastSideChainState = false; | bool hasSidechain = false, canDisableSidechain = false, lastSideChainState = false; | ||||
| Atomic<int> processingSidechainChange, sidechainDesired; | |||||
| std::atomic<bool> processingSidechainChange, sidechainDesired; | |||||
| HeapBlock<float> sideChainBuffer; | HeapBlock<float> sideChainBuffer; | ||||
| Array<int> inputLayoutMap, outputLayoutMap; | Array<int> inputLayoutMap, outputLayoutMap; | ||||