Skip to content

Commit

Permalink
Fix occasional Sinnah hang
Browse files Browse the repository at this point in the history
  • Loading branch information
DomClark authored and zonkmachine committed Dec 7, 2018
1 parent 277e8b6 commit 3a94ed3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 1 addition & 8 deletions include/InstrumentPlayHandle.h
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions plugins/vst_base/RemoteVstPlugin.cpp
Expand Up @@ -63,6 +63,7 @@
#define USE_WS_PREFIX
#include <windows.h>

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

0 comments on commit 3a94ed3

Please sign in to comment.