--- linuxsampler/trunk/src/engines/EngineBase.h 2010/09/22 18:59:16 2127 +++ linuxsampler/trunk/src/engines/EngineBase.h 2011/02/08 18:22:50 2162 @@ -4,7 +4,7 @@ * * * Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * * Copyright (C) 2005-2008 Christian Schoenebeck * - * Copyright (C) 2009-2010 Christian Schoenebeck and Grigor Iliev * + * Copyright (C) 2009-2011 Christian Schoenebeck and Grigor Iliev * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -190,6 +190,15 @@ // been deleted by the disk thread if (iPendingStreamDeletions) ProcessPendingStreamDeletions(); + // Release the instrument change command. (This has to + // be done after all voices have been rendered and not + // in HandleInstrumentChanges, as the RegionsInUse + // list has been built up by the voice renderers.) + for (int i = 0; i < engineChannels.size(); i++) { + EngineChannelBase* channel = + static_cast*>(engineChannels[i]); + channel->InstrumentChangeCommandReader.Unlock(); + } FrameTime += Samples; EngineDisabled.RttDone(); @@ -772,12 +781,6 @@ //TODO: this is a lazy solution ATM and not safe in case somebody is currently editing the instrument we're currently switching to (we should store all suspended regions on instrument manager side and when switching to another instrument copy that list to the engine's local list of suspensions ResetSuspendedRegions(); } - - for (int i = 0; i < engineChannels.size(); i++) { - EngineChannelBase* channel = - static_cast*>(engineChannels[i]); - channel->InstrumentChangeCommandReader.Unlock(); - } } /**