mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
VST2: Fixed a potential race condition when getting and setting plug-in state
This commit is contained in:
parent
6f4d212ca6
commit
1c0eb583f1
1 changed files with 26 additions and 15 deletions
|
|
@ -1110,12 +1110,16 @@ public:
|
|||
deleteEditor (true);
|
||||
}
|
||||
|
||||
if (chunkMemoryTime > 0
|
||||
&& chunkMemoryTime < juce::Time::getApproximateMillisecondCounter() - 2000
|
||||
&& ! recursionCheck)
|
||||
{
|
||||
chunkMemory.reset();
|
||||
chunkMemoryTime = 0;
|
||||
ScopedLock lock (stateInformationLock);
|
||||
|
||||
if (chunkMemoryTime > 0
|
||||
&& chunkMemoryTime < juce::Time::getApproximateMillisecondCounter() - 2000
|
||||
&& ! recursionCheck)
|
||||
{
|
||||
chunkMemory.reset();
|
||||
chunkMemoryTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (editorComp != nullptr)
|
||||
|
|
@ -1857,7 +1861,9 @@ private:
|
|||
auto data = (void**) args.ptr;
|
||||
bool onlyStoreCurrentProgramData = (args.index != 0);
|
||||
|
||||
ScopedLock lock (stateInformationLock);
|
||||
chunkMemory.reset();
|
||||
|
||||
if (onlyStoreCurrentProgramData)
|
||||
processor->getCurrentProgramStateInformation (chunkMemory);
|
||||
else
|
||||
|
|
@ -1880,15 +1886,19 @@ private:
|
|||
int32 byteSize = (int32) args.value;
|
||||
bool onlyRestoreCurrentProgramData = (args.index != 0);
|
||||
|
||||
chunkMemory.reset();
|
||||
chunkMemoryTime = 0;
|
||||
|
||||
if (byteSize > 0 && data != nullptr)
|
||||
{
|
||||
if (onlyRestoreCurrentProgramData)
|
||||
processor->setCurrentProgramStateInformation (data, byteSize);
|
||||
else
|
||||
processor->setStateInformation (data, byteSize);
|
||||
ScopedLock lock (stateInformationLock);
|
||||
|
||||
chunkMemory.reset();
|
||||
chunkMemoryTime = 0;
|
||||
|
||||
if (byteSize > 0 && data != nullptr)
|
||||
{
|
||||
if (onlyRestoreCurrentProgramData)
|
||||
processor->setCurrentProgramStateInformation (data, byteSize);
|
||||
else
|
||||
processor->setStateInformation (data, byteSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2272,8 +2282,9 @@ private:
|
|||
double sampleRate = 44100.0;
|
||||
int32 blockSize = 1024;
|
||||
Vst2::AEffect vstEffect;
|
||||
juce::MemoryBlock chunkMemory;
|
||||
juce::uint32 chunkMemoryTime = 0;
|
||||
CriticalSection stateInformationLock;
|
||||
MemoryBlock chunkMemory;
|
||||
uint32 chunkMemoryTime = 0;
|
||||
std::unique_ptr<EditorCompWrapper> editorComp;
|
||||
Vst2::ERect editorBounds;
|
||||
MidiBuffer midiEvents;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue