From 9e4d212959e73a72a977f74f55973a06eef92a12 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 4 Aug 2007 08:01:42 +0000 Subject: [PATCH] acquire play-handle-lock of mixer while calling noteOff() in instrumentTrack::processInEvent( ... ) - fixes asynchronously modifications of variables in notePlayHandle which led to segfaults in some cases git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@506 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 10 +++++++++- src/tracks/instrument_track.cpp | 14 +++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f035f63dc..fc3566f33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,12 @@ -2007-08-04 Tobias Doerffel +2007-08-03 Tobias Doerffel + + * src/tracks/instrument_track.cpp: + acquire play-handle-lock of mixer while calling noteOff() in + instrumentTrack::processInEvent( ... ) - fixes asynchronously + modifications of variables in notePlayHandle which led to segfaults in + some cases + +2007-08-03 Tobias Doerffel * plugins/audio_file_processor/audio_file_processor.cpp: * plugins/bit_invader/bit_invader.cpp: diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index 3823c3baa..47f92102e 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -642,9 +642,10 @@ void instrumentTrack::processInEvent( const midiEvent & _me, } case NOTE_OFF: - if( m_notes[_me.key()] != NULL ) + { + notePlayHandle * n = m_notes[_me.key()]; + if( n != NULL ) { - notePlayHandle * n = m_notes[_me.key()]; // create dummy-note which has the same length // as the played note for sending it later // to all slots connected to signal noteDone() @@ -656,18 +657,25 @@ void instrumentTrack::processInEvent( const midiEvent & _me, engine::framesPerTact64th() ) ), 0, n->tone(), n->octave(), n->getVolume(), n->getPanning() ); + // lock our play-handle while calling noteOff() + // for not modifying it's member variables + // asynchronously (while rendering!) + // which can result in segfaults + engine::getMixer()->lockPlayHandles(); n->noteOff(); + engine::getMixer()->unlockPlayHandles(); m_notes[_me.key()] = NULL; emit noteDone( done_note ); } break; + } case KEY_PRESSURE: if( !m_instrument->handleMidiEvent( _me, _time ) && m_notes[_me.key()] != NULL ) { m_notes[_me.key()]->setVolume( _me.velocity() * - 100 / 128 ); + 100 / 127 ); } break;