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
This commit is contained in:
Tobias Doerffel
2007-08-04 08:01:42 +00:00
parent d0370bb4e9
commit 9e4d212959
2 changed files with 20 additions and 4 deletions

View File

@@ -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;