Skip to content
Permalink
Browse files

Fix occasional Sinnah hang

  • Loading branch information...
DomClark authored and zonkmachine committed Nov 25, 2018
1 parent 277e8b6 commit 3a94ed3f3fecbd23227401212d112b4cff773d31
Showing with 10 additions and 8 deletions.
  1. +1 −8 include/InstrumentPlayHandle.h
  2. +9 −0 plugins/vst_base/RemoteVstPlugin.cpp
@@ -42,14 +42,7 @@ class EXPORT InstrumentPlayHandle : public PlayHandle

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;
@@ -63,6 +63,7 @@
#define USE_WS_PREFIX
#include <windows.h>

#include <algorithm>
#include <vector>
#include <queue>
#include <string>
@@ -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();

0 comments on commit 3a94ed3

Please sign in to comment.
You can’t perform that action at this time.