From 2470df4f0ea2abcbd76a83454c0f6db4b8c3d8c3 Mon Sep 17 00:00:00 2001 From: midi-pascal Date: Thu, 22 Oct 2015 15:39:46 -0400 Subject: [PATCH] Remove note from m_playingNotes before deleting its m_pluginData in sf2Instrument::deleteNotePluginData() Move m_playingNotesMutex.lock() and m_playingNotesMutex.unlock() outside of if( m_playingNotes.indexOf( _n ) >= 0 ) Conflicts: plugins/sf2_player/sf2_player.cpp Remove note from m_playingNotes before deleting its m_pluginData in sf2Instrument::deleteNotePluginData() Move m_playingNotesMutex.lock() and m_playingNotesMutex.unlock() outside of if( m_playingNotes.indexOf( _n ) >= 0 ) --- plugins/sf2_player/sf2_player.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index 07c4a0e04..8d633d6d3 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -711,16 +711,20 @@ void sf2Instrument::play( sampleFrame * _working_buffer ) } else // otherwise remove the handle { + m_playingNotesMutex.lock(); m_playingNotes.remove( m_playingNotes.indexOf( currentNote ) ); + m_playingNotesMutex.unlock(); } } else { noteOff( currentData ); + m_playingNotesMutex.lock(); m_playingNotes.remove( m_playingNotes.indexOf( currentNote ) ); + m_playingNotesMutex.unlock(); } } - + if( currentFrame < frames ) { renderFrames( frames - currentFrame, _working_buffer + currentFrame ); @@ -780,6 +784,12 @@ void sf2Instrument::deleteNotePluginData( NotePlayHandle * _n ) // do it here { noteOff( pluginData ); + m_playingNotesMutex.lock(); + if( m_playingNotes.indexOf( _n ) >= 0 ) + { + m_playingNotes.remove( m_playingNotes.indexOf( _n ) ); + } + m_playingNotesMutex.unlock(); } delete pluginData; }