diff --git a/source/modules/native-plugins/zynaddsubfx-synth.cpp b/source/modules/native-plugins/zynaddsubfx-synth.cpp index 10d901ff0..2b4b4ef1d 100644 --- a/source/modules/native-plugins/zynaddsubfx-synth.cpp +++ b/source/modules/native-plugins/zynaddsubfx-synth.cpp @@ -552,6 +552,9 @@ public: fMaster->partonoff(i, 1); sPrograms.init(); + + // create instance if needed + getGlobalMutex(); } ~ZynAddSubFxPlugin() override @@ -627,6 +630,8 @@ protected: return; } + const CarlaMutexLocker csm(getGlobalMutex()); + for (uint32_t i=0; i < midiEventCount; ++i) { const NativeMidiEvent* const midiEvent(&midiEvents[i]); @@ -765,6 +770,16 @@ private: ZynAddSubFxThread fThread; + // ------------------------------------------------------------------- + + static CarlaMutex& getGlobalMutex() noexcept + { + static CarlaMutex m; + return m; + } + + // ------------------------------------------------------------------- + public: static NativePluginHandle _instantiate(const NativeHostDescriptor* host) {