/[svn]/linuxsampler/trunk/src/engines/common/InstrumentScriptVM.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/InstrumentScriptVM.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3691 by schoenebeck, Fri Jan 3 12:35:20 2020 UTC revision 3802 by schoenebeck, Fri Jul 31 15:07:04 2020 UTC
# Line 88  namespace LinuxSampler { Line 88  namespace LinuxSampler {
88       * channels.       * channels.
89       *       *
90       * @param text - source code of script       * @param text - source code of script
91         * @param patchVars - 'patch' variables being overridden by instrument
92       */       */
93      void InstrumentScript::load(const String& text) {      void InstrumentScript::load(const String& text,
94                                    const std::map<String,String>& patchVars)
95        {
96          dmsg(1,("Loading real-time instrument script ... "));          dmsg(1,("Loading real-time instrument script ... "));
97    
98          // hand back old script reference and VM execution contexts          // hand back old script reference and VM execution contexts
# Line 102  namespace LinuxSampler { Line 105  namespace LinuxSampler {
105              dynamic_cast<AbstractInstrumentManager*>(pEngineChannel->pEngine->GetInstrumentManager());              dynamic_cast<AbstractInstrumentManager*>(pEngineChannel->pEngine->GetInstrumentManager());
106    
107          // get new script reference          // get new script reference
108          parserContext = pManager->scripts.Borrow(text, pEngineChannel);          parserContext = pManager->scripts.Borrow(
109                { .code = text, .patchVars = patchVars }, pEngineChannel
110            );
111          if (!parserContext->errors().empty()) {          if (!parserContext->errors().empty()) {
112              std::vector<ParserIssue> errors = parserContext->errors();              std::vector<ParserIssue> errors = parserContext->errors();
113              std::cerr << "[ScriptVM] Could not load instrument script, there were "              std::cerr << "[ScriptVM] Could not load instrument script, there were "
# Line 139  namespace LinuxSampler { Line 144  namespace LinuxSampler {
144                  RTList<ScriptEvent>::Iterator it = pEvents->allocAppend();                  RTList<ScriptEvent>::Iterator it = pEvents->allocAppend();
145                  it->reset();                  it->reset();
146              }              }
             pEvents->clear();  
147          }          }
148            pEvents->clear(); // outside of upper block, as loop below must always start from cleared list
149    
150          // create new VM execution contexts for new script          // create new VM execution contexts for new script
151          while (!pEvents->poolIsEmpty()) {          while (!pEvents->poolIsEmpty()) {
# Line 179  namespace LinuxSampler { Line 184  namespace LinuxSampler {
184              pEvents->clear();              pEvents->clear();
185              while (!pEvents->poolIsEmpty()) {              while (!pEvents->poolIsEmpty()) {
186                  RTList<ScriptEvent>::Iterator it = pEvents->allocAppend();                  RTList<ScriptEvent>::Iterator it = pEvents->allocAppend();
187                    if (!it) break;
188                  if (it->execCtx) {                  if (it->execCtx) {
189                      // free VM execution context object                      // free VM execution context object
190                      delete it->execCtx;                      delete it->execCtx;
191                      it->execCtx = NULL;                      it->execCtx = NULL;
192                      // free C array of handler pointers                      // free C array of handler pointers
193                      delete [] it->handlers;                      delete [] it->handlers;
194                        it->handlers = NULL;
195                  }                  }
196              }              }
197              pEvents->clear();              pEvents->clear();

Legend:
Removed from v.3691  
changed lines
  Added in v.3802

  ViewVC Help
Powered by ViewVC