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-2015 Christian Schoenebeck and Grigor Iliev * |
* Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev * |
8 |
|
* Copyright (C) 2012-2016 Christian Schoenebeck and Andreas Persson * |
9 |
* * |
* * |
10 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
11 |
* 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 * |
134 |
LockGuard lock(EngineMutex); |
LockGuard lock(EngineMutex); |
135 |
pEngine = newEngine; |
pEngine = newEngine; |
136 |
} |
} |
137 |
ResetInternal(); |
ResetInternal(false/*don't reset engine*/); // 'false' is error prone here, but the danger of recursion with 'true' would be worse, there could be a better solution though |
138 |
pEvents = new RTList<Event>(pEngine->pEventPool); |
pEvents = new RTList<Event>(pEngine->pEventPool); |
139 |
|
delayedEvents.pList = new RTList<Event>(pEngine->pEventPool); |
140 |
|
|
141 |
RegionPools<R>* pRegionPool = dynamic_cast<RegionPools<R>*>(pEngine); |
RegionPools<R>* pRegionPool = dynamic_cast<RegionPools<R>*>(pEngine); |
142 |
// reset the instrument change command struct (need to be done |
// reset the instrument change command struct (need to be done |
186 |
virtual void DisconnectAudioOutputDevice() { |
virtual void DisconnectAudioOutputDevice() { |
187 |
if (pEngine) { // if clause to prevent disconnect loops |
if (pEngine) { // if clause to prevent disconnect loops |
188 |
|
|
189 |
ResetInternal(); |
ResetInternal(false/*don't reset engine*/); // 'false' is error prone here, but the danger of recursion with 'true' would be worse, there could be a better solution though |
190 |
|
|
191 |
DeleteRegionsInUse(); |
DeleteRegionsInUse(); |
192 |
UnloadScriptInUse(); |
UnloadScriptInUse(); |
201 |
delete pEvents; |
delete pEvents; |
202 |
pEvents = NULL; |
pEvents = NULL; |
203 |
} |
} |
204 |
|
if (delayedEvents.pList) { |
205 |
|
delete delayedEvents.pList; |
206 |
|
delayedEvents.pList = NULL; |
207 |
|
} |
208 |
|
|
209 |
MidiKeyboardManager<V>::DeleteActiveVoices(); |
MidiKeyboardManager<V>::DeleteActiveVoices(); |
210 |
MidiKeyboardManager<V>::DeleteEvents(); |
MidiKeyboardManager<V>::DeleteEvents(); |
232 |
virtual bool Process(MidiKey* pMidiKey) { pMidiKey->pEvents->clear(); return false; } |
virtual bool Process(MidiKey* pMidiKey) { pMidiKey->pEvents->clear(); return false; } |
233 |
}; |
}; |
234 |
|
|
235 |
void ClearEventLists() { |
/** |
236 |
|
* Free all events of the current audio fragment cycle. Calling |
237 |
|
* this method will @b NOT free events scheduled past the current |
238 |
|
* fragment's boundary! (@see AbstractEngineChannel::delayedEvents). |
239 |
|
*/ |
240 |
|
void ClearEventListsOfCurrentFragment() { |
241 |
pEvents->clear(); |
pEvents->clear(); |
242 |
// empty MIDI key specific event lists |
// empty MIDI key specific event lists |
243 |
ClearEventListsHandler handler; |
ClearEventListsHandler handler; |
260 |
virtual void ResourceToBeUpdated(I* pResource, void*& pUpdateArg) OVERRIDE { |
virtual void ResourceToBeUpdated(I* pResource, void*& pUpdateArg) OVERRIDE { |
261 |
dmsg(3,("EngineChannelBase: Received instrument update message.\n")); |
dmsg(3,("EngineChannelBase: Received instrument update message.\n")); |
262 |
if (pEngine) pEngine->DisableAndLock(); |
if (pEngine) pEngine->DisableAndLock(); |
263 |
ResetInternal(); |
ResetInternal(false/*don't reset engine*/); |
264 |
this->pInstrument = NULL; |
this->pInstrument = NULL; |
265 |
} |
} |
266 |
|
|
381 |
SyncConfInstrChangeCmdReader InstrumentChangeCommandReader; |
SyncConfInstrChangeCmdReader InstrumentChangeCommandReader; |
382 |
|
|
383 |
/** This method is not thread safe! */ |
/** This method is not thread safe! */ |
384 |
virtual void ResetInternal() { |
virtual void ResetInternal(bool bResetEngine) OVERRIDE { |
385 |
AbstractEngineChannel::ResetInternal(); |
AbstractEngineChannel::ResetInternal(bResetEngine); |
386 |
|
|
387 |
MidiKeyboardManager<V>::Reset(); |
MidiKeyboardManager<V>::Reset(); |
388 |
} |
} |