/[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 3848 by schoenebeck, Thu Jan 7 13:52:46 2021 UTC revision 3971 by schoenebeck, Fri Jun 25 09:26:00 2021 UTC
# Line 106  namespace LinuxSampler { Line 106  namespace LinuxSampler {
106          AbstractInstrumentManager* pManager =          AbstractInstrumentManager* pManager =
107              dynamic_cast<AbstractInstrumentManager*>(pEngineChannel->pEngine->GetInstrumentManager());              dynamic_cast<AbstractInstrumentManager*>(pEngineChannel->pEngine->GetInstrumentManager());
108    
109          // get new script reference          /*
110          parserContext = pManager->scripts.Borrow(             Get new script reference.
111              { .code = text, .patchVars = patchVars }, pEngineChannel  
112               Note: every engine channel now has its own compiled script object
113               (a.k.a. VMParserContext). Originally a compiled script was shared by
114               multiple engine channels. This was wrong: we cannot share compiled
115               script instances among multiple engine channels (parts), for two
116               reasons:
117    
118               1. VMParserContext not only encompasses the compiled tree
119                  presentation of the requested script, but also global variables
120                  and we don't want those global variables to be modified by
121                  different sampler parts, as this would not be expected behaviour
122                  by instrument script authors.
123    
124               2. If there is more than one sampler engine instance (e.g. if there
125                  are multiple audio output device instances) this would even crash,
126                  because each sampler engine instance has its own ScriptVM
127                  instance, and a (VM)ParserContext is always tied to exactly one
128                  ScriptVM instance.
129    
130               We would not be buying much by sharing compiled scripts anyway, as a
131               script usually compiles in couple microseconds and RAM usage is also
132               neglectable.
133            */
134            parserContext = pManager->scripts.Borrow({
135                    .code = text,
136                    .patchVars = patchVars,
137                    .engineChannel = pEngineChannel /* unique owner of script */
138                },
139                pEngineChannel /* who is asking to borrow */
140          );          );
141          if (!parserContext->errors().empty()) {          if (!parserContext->errors().empty()) {
142              std::vector<ParserIssue> errors = parserContext->errors();              std::vector<ParserIssue> errors = parserContext->errors();

Legend:
Removed from v.3848  
changed lines
  Added in v.3971

  ViewVC Help
Powered by ViewVC