From 8586a7d30fee3fd2f1ff360b9fe51a961b3adede Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 3 Mar 2008 22:51:23 +0000 Subject: [PATCH] do not lock mixer and call notePlayHandle::noteOff() in instrumentTrack::processInEvent() when processing monophonic instruments in playNote() - fixes lockups in LB302 in multithreaded mode git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@753 0778d3d1-df1d-0410-868b-ea421aaaa00d --- include/instrument_track.h | 3 ++- include/midi_event_processor.h | 5 +++-- src/tracks/instrument_track.cpp | 29 +++++++++++++---------------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/include/instrument_track.h b/include/instrument_track.h index 2f7eaa560..e8b1c7e3f 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -74,7 +74,8 @@ public: notePlayHandle * _n ); virtual void processInEvent( const midiEvent & _me, - const midiTime & _time ); + const midiTime & _time, + bool _lock = TRUE ); virtual void processOutEvent( const midiEvent & _me, const midiTime & _time ); diff --git a/include/midi_event_processor.h b/include/midi_event_processor.h index 1db3959f0..d279a6d5f 100644 --- a/include/midi_event_processor.h +++ b/include/midi_event_processor.h @@ -1,7 +1,7 @@ /* * midi_event_processor.h - base-class for midi-processing classes * - * Copyright (c) 2005-2007 Tobias Doerffel + * Copyright (c) 2005-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -49,7 +49,8 @@ public: // to be implemented by inheriting classes virtual void FASTCALL processInEvent( const midiEvent & _me, - const midiTime & _time ) = 0; + const midiTime & _time, + bool _lock = TRUE ) = 0; virtual void FASTCALL processOutEvent( const midiEvent & _me, const midiTime & _time ) = 0; diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index b6633d8f4..45d70cc01 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -204,7 +204,7 @@ void instrumentTrack::processAudioBuffer( sampleFrame * _buf, void instrumentTrack::processInEvent( const midiEvent & _me, - const midiTime & _time ) + const midiTime & _time, bool _lock ) { switch( _me.m_type ) { @@ -257,13 +257,16 @@ 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()->lock(); - n->noteOff(); - engine::getMixer()->unlock(); + if( _lock ) + { + // lock our play-handle while calling noteOff() + // for not modifying it's member variables + // asynchronously (while rendering!) + // which can result in segfaults + engine::getMixer()->lock(); + n->noteOff(); + engine::getMixer()->unlock(); + } m_notes[_me.key()] = NULL; emit noteDone( done_note ); } @@ -380,7 +383,8 @@ void instrumentTrack::playNote( notePlayHandle * _n, bool _try_parallelizing ) !_n->released() ) { processInEvent( midiEvent( NOTE_OFF, 0, - _n->key(), 0 ), midiTime() ); + _n->key(), 0 ), midiTime(), + FALSE ); if( ( *youngest_note )->offset() > _n->offset() ) { @@ -404,13 +408,6 @@ void instrumentTrack::playNote( notePlayHandle * _n, bool _try_parallelizing ) return; } } - // we do not play previously released notes - // anymore - else if( *youngest_note != _n && - _n->released() ) - { - //return; - } } } // all is done, so now lets play the note!