From 3a94ed3f3fecbd23227401212d112b4cff773d31 Mon Sep 17 00:00:00 2001 From: Dominic Clark Date: Sun, 25 Nov 2018 15:55:38 +0000 Subject: [PATCH] Fix occasional Sinnah hang --- include/InstrumentPlayHandle.h | 9 +-------- plugins/vst_base/RemoteVstPlugin.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/InstrumentPlayHandle.h b/include/InstrumentPlayHandle.h index 726859237..02d6fc69c 100644 --- a/include/InstrumentPlayHandle.h +++ b/include/InstrumentPlayHandle.h @@ -42,14 +42,7 @@ public: virtual void play( sampleFrame * _working_buffer ) { - // if the instrument is midi-based, we can safely render right away - if( m_instrument->flags() & Instrument::IsMidiBased ) - { - m_instrument->play( _working_buffer ); - return; - } - - // if not, we need to ensure that all our nph's have been processed first + // ensure that all our nph's have been processed first ConstNotePlayHandleList nphv = NotePlayHandle::nphsOfInstrumentTrack( m_instrument->instrumentTrack(), true ); bool nphsLeft; diff --git a/plugins/vst_base/RemoteVstPlugin.cpp b/plugins/vst_base/RemoteVstPlugin.cpp index 4a41aea0c..e0fcb3ba6 100644 --- a/plugins/vst_base/RemoteVstPlugin.cpp +++ b/plugins/vst_base/RemoteVstPlugin.cpp @@ -63,6 +63,7 @@ #define USE_WS_PREFIX #include +#include #include #include #include @@ -900,6 +901,14 @@ void RemoteVstPlugin::process( const sampleFrame * _in, sampleFrame * _out ) static char eventsBuffer[sizeof( VstEvents ) + sizeof( VstMidiEvent * ) * MIDI_EVENT_BUFFER_COUNT]; static VstMidiEvent vme[MIDI_EVENT_BUFFER_COUNT]; + // first sort events chronologically, since some plugins + // (e.g. Sinnah) can hang if they're out of order + std::stable_sort( m_midiEvents.begin(), m_midiEvents.end(), + []( const VstMidiEvent &a, const VstMidiEvent &b ) + { + return a.deltaFrames < b.deltaFrames; + } ); + VstEvents* events = (VstEvents *) eventsBuffer; events->reserved = 0; events->numEvents = m_midiEvents.size();