4 |
* * |
* * |
5 |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005-2008 Christian Schoenebeck * |
* Copyright (C) 2005-2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009-2011 Christian Schoenebeck and Grigor Iliev * |
* Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev * |
8 |
* * |
* * |
9 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
10 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
120 |
if (pEngine->pAudioOutputDevice == pAudioOut) return; |
if (pEngine->pAudioOutputDevice == pAudioOut) return; |
121 |
DisconnectAudioOutputDevice(); |
DisconnectAudioOutputDevice(); |
122 |
} |
} |
123 |
pEngine = AbstractEngine::AcquireEngine(this, pAudioOut); |
AbstractEngine* newEngine = AbstractEngine::AcquireEngine(this, pAudioOut); |
124 |
|
EngineMutex.Lock(); |
125 |
|
pEngine = newEngine; |
126 |
|
EngineMutex.Unlock(); |
127 |
ResetInternal(); |
ResetInternal(); |
128 |
pEvents = new RTList<Event>(pEngine->pEventPool); |
pEvents = new RTList<Event>(pEngine->pEventPool); |
129 |
|
|
195 |
DeleteGroupEventLists(); |
DeleteGroupEventLists(); |
196 |
|
|
197 |
AudioOutputDevice* oldAudioDevice = pEngine->pAudioOutputDevice; |
AudioOutputDevice* oldAudioDevice = pEngine->pAudioOutputDevice; |
198 |
|
EngineMutex.Lock(); |
199 |
pEngine = NULL; |
pEngine = NULL; |
200 |
|
EngineMutex.Unlock(); |
201 |
AbstractEngine::FreeEngine(this, oldAudioDevice); |
AbstractEngine::FreeEngine(this, oldAudioDevice); |
202 |
AudioDeviceChannelLeft = -1; |
AudioDeviceChannelLeft = -1; |
203 |
AudioDeviceChannelRight = -1; |
AudioDeviceChannelRight = -1; |
219 |
pEvents->clear(); |
pEvents->clear(); |
220 |
// empty MIDI key specific event lists |
// empty MIDI key specific event lists |
221 |
ClearEventListsHandler handler; |
ClearEventListsHandler handler; |
222 |
ProcessActiveVoices(&handler); |
this->ProcessActiveVoices(&handler); |
223 |
|
|
224 |
// empty exclusive group specific event lists |
// empty exclusive group specific event lists |
225 |
ClearGroupEventLists(); |
// (pInstrument == 0 could mean that LoadInstrument is |
226 |
|
// building new group event lists, so we must check |
227 |
|
// for that) |
228 |
|
if (pInstrument) ClearGroupEventLists(); |
229 |
} |
} |
230 |
|
|
231 |
// implementation of abstract methods derived from interface class 'InstrumentConsumer' |
// implementation of abstract methods derived from interface class 'InstrumentConsumer' |
266 |
|
|
267 |
void RenderActiveVoices(uint Samples) { |
void RenderActiveVoices(uint Samples) { |
268 |
RenderVoicesHandler handler(this, Samples); |
RenderVoicesHandler handler(this, Samples); |
269 |
ProcessActiveVoices(&handler); |
this->ProcessActiveVoices(&handler); |
270 |
|
|
271 |
SetVoiceCount(handler.VoiceCount); |
SetVoiceCount(handler.VoiceCount); |
272 |
SetDiskStreamCount(handler.StreamCount); |
SetDiskStreamCount(handler.StreamCount); |
324 |
if ((itVoice->DiskStreamRef).State != Stream::state_unused) StreamCount++; |
if ((itVoice->DiskStreamRef).State != Stream::state_unused) StreamCount++; |
325 |
} |
} |
326 |
} else { // voice reached end, is now inactive |
} else { // voice reached end, is now inactive |
327 |
|
itVoice->VoiceFreed(); |
328 |
pChannel->FreeVoice(itVoice); // remove voice from the list of active voices |
pChannel->FreeVoice(itVoice); // remove voice from the list of active voices |
329 |
} |
} |
330 |
} |
} |