From a0d6115482173122d5693a4f09a119fc3743cf62 Mon Sep 17 00:00:00 2001 From: Vesa Date: Fri, 13 Jun 2014 19:43:37 +0300 Subject: [PATCH] A fix to IPH waiting code: don't wait for already finished notes, plus a bit of optimization --- include/InstrumentPlayHandle.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/InstrumentPlayHandle.h b/include/InstrumentPlayHandle.h index c2fd5c918..1e1b7d5da 100644 --- a/include/InstrumentPlayHandle.h +++ b/include/InstrumentPlayHandle.h @@ -56,14 +56,21 @@ public: // if not, we need to ensure that all our nph's have been processed first ConstNotePlayHandleList nphv = NotePlayHandle::nphsOfInstrumentTrack( m_instrument->instrumentTrack(), true ); - foreach( const NotePlayHandle * cnph, nphv ) + bool nphsLeft; + do { - NotePlayHandle * nph = const_cast( cnph ); - while( nph->state() != ThreadableJob::Done ) + nphsLeft = false; + foreach( const NotePlayHandle * cnph, nphv ) { - nph->process(); + NotePlayHandle * nph = const_cast( cnph ); + if( nph->state() != ThreadableJob::Done && ! nph->isFinished() ) + { + nphsLeft = true; + nph->process(); + } } } + while( nphsLeft ); m_instrument->play( _working_buffer ); }