85 |
} |
} |
86 |
|
|
87 |
virtual void DeleteRegionsInUse() { |
virtual void DeleteRegionsInUse() { |
88 |
|
RTList<R*>* previous = NULL; // prevent double free |
89 |
{ |
{ |
90 |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
91 |
if (cmd.pRegionsInUse) { |
if (cmd.pRegionsInUse) { |
92 |
|
previous = cmd.pRegionsInUse; |
93 |
delete cmd.pRegionsInUse; |
delete cmd.pRegionsInUse; |
94 |
cmd.pRegionsInUse = NULL; |
cmd.pRegionsInUse = NULL; |
95 |
} |
} |
98 |
{ |
{ |
99 |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.SwitchConfig(); |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.SwitchConfig(); |
100 |
if (cmd.pRegionsInUse) { |
if (cmd.pRegionsInUse) { |
101 |
delete cmd.pRegionsInUse; |
if (cmd.pRegionsInUse != previous) |
102 |
|
delete cmd.pRegionsInUse; |
103 |
cmd.pRegionsInUse = NULL; |
cmd.pRegionsInUse = NULL; |
104 |
} |
} |
105 |
cmd.bChangeInstrument = false; |
cmd.bChangeInstrument = false; |
183 |
ResetInternal(); |
ResetInternal(); |
184 |
|
|
185 |
DeleteRegionsInUse(); |
DeleteRegionsInUse(); |
186 |
|
UnloadScriptInUse(); |
187 |
|
|
188 |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
189 |
if (cmd.pInstrument) { |
if (cmd.pInstrument) { |
307 |
} |
} |
308 |
|
|
309 |
virtual ~EngineChannelBase() { |
virtual ~EngineChannelBase() { |
310 |
|
InstrumentScript* previous = NULL; // prevent double free |
311 |
{ |
{ |
312 |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
313 |
if (cmd.pScript) delete cmd.pScript; |
if (cmd.pScript) { |
314 |
|
previous = cmd.pScript; |
315 |
|
delete cmd.pScript; |
316 |
|
cmd.pScript = NULL; |
317 |
|
} |
318 |
} |
} |
319 |
{ |
{ |
320 |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.SwitchConfig(); |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.SwitchConfig(); |
321 |
if (cmd.pScript) delete cmd.pScript; |
if (cmd.pScript) { |
322 |
|
if (previous != cmd.pScript) |
323 |
|
delete cmd.pScript; |
324 |
|
cmd.pScript = NULL; |
325 |
|
} |
326 |
} |
} |
327 |
} |
} |
328 |
|
|
377 |
} |
} |
378 |
|
|
379 |
/** |
/** |
380 |
|
* Unload the currently used and loaded real-time instrument script. |
381 |
|
* The source code of the script is retained, so that it can still |
382 |
|
* be reloaded. |
383 |
|
*/ |
384 |
|
void UnloadScriptInUse() { |
385 |
|
{ |
386 |
|
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
387 |
|
if (cmd.pScript) pScript->unload(); |
388 |
|
} |
389 |
|
{ |
390 |
|
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.SwitchConfig(); |
391 |
|
if (cmd.pScript) pScript->unload(); |
392 |
|
} |
393 |
|
} |
394 |
|
|
395 |
|
/** |
396 |
* Load real-time instrument script and all its resources required |
* Load real-time instrument script and all its resources required |
397 |
* for the upcoming instrument change. |
* for the upcoming instrument change. |
398 |
* |
* |
400 |
*/ |
*/ |
401 |
void LoadInstrumentScript(const String& text) { |
void LoadInstrumentScript(const String& text) { |
402 |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
InstrumentChangeCmd<R, I>& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
|
// unload *PRE*-previous script |
|
|
cmd.pScript->reset(); //TODO: previous script should be freed as soon as the EngineBase switched the instrument, right now 2 scripts are kept in memory all the time, even though the old one is not used anymore |
|
403 |
// load the new script |
// load the new script |
404 |
cmd.pScript->load(text); |
cmd.pScript->load(text); |
405 |
} |
} |