diff --git a/Source/Processors/LfpDisplayNode/LfpDisplayCanvas.cpp b/Source/Processors/LfpDisplayNode/LfpDisplayCanvas.cpp index 0c42087651027db6c9251ab8f7ae5c5a38a925cc..03791626e8efe8ecf8d6114e1b1bd26c95a3635b 100755 --- a/Source/Processors/LfpDisplayNode/LfpDisplayCanvas.cpp +++ b/Source/Processors/LfpDisplayNode/LfpDisplayCanvas.cpp @@ -658,6 +658,8 @@ void LfpDisplayCanvas::updateScreenBuffer() // copy new samples from the displayBuffer into the screenBuffer int maxSamples = lfpDisplay->getWidth() - leftmargin; + ScopedLock displayLock(*processor->getMutex()); + for (int channel = 0; channel <= nChans; channel++) // pull one extra channel for event display { diff --git a/Source/Processors/LfpDisplayNode/LfpDisplayNode.cpp b/Source/Processors/LfpDisplayNode/LfpDisplayNode.cpp index 5092af2869b63c8bcfb2fb34b9a0369f52241d5e..c89c4611e42319f3b6fad821be5339421a93d0b2 100755 --- a/Source/Processors/LfpDisplayNode/LfpDisplayNode.cpp +++ b/Source/Processors/LfpDisplayNode/LfpDisplayNode.cpp @@ -297,6 +297,8 @@ void LfpDisplayNode::process(AudioSampleBuffer& buffer, MidiBuffer& events) checkForEvents(events); // see if we got any TTL events + ScopedLock displayLock(displayMutex); + for (int chan = 0; chan < buffer.getNumChannels(); chan++) { int samplesLeft = displayBuffer->getNumSamples() - displayBufferIndex[chan]; diff --git a/Source/Processors/LfpDisplayNode/LfpDisplayNode.h b/Source/Processors/LfpDisplayNode/LfpDisplayNode.h index a475e19f35f5849822b23b5833da402389c00b99..18426bb7f2e38ece3905652fdd619898ee5504a5 100755 --- a/Source/Processors/LfpDisplayNode/LfpDisplayNode.h +++ b/Source/Processors/LfpDisplayNode/LfpDisplayNode.h @@ -75,6 +75,11 @@ public: return displayBufferIndex[chan]; } + CriticalSection* getMutex() + { + return &displayMutex; + } + private: void initializeEventChannels(); @@ -99,6 +104,8 @@ private: bool resizeBuffer(); + CriticalSection displayMutex; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LfpDisplayNode); };