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

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

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

revision 3214 by schoenebeck, Thu May 25 14:46:47 2017 UTC revision 3317 by schoenebeck, Thu Jul 20 12:18:45 2017 UTC
# Line 23  namespace LinuxSampler { Line 23  namespace LinuxSampler {
23      VMFnResult* InstrumentScriptVMFunction_play_note::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_play_note::exec(VMFnArgs* args) {
24          int note = args->arg(0)->asInt()->evalInt();          int note = args->arg(0)->asInt()->evalInt();
25          int velocity = (args->argsCount() >= 2) ? args->arg(1)->asInt()->evalInt() : 127;          int velocity = (args->argsCount() >= 2) ? args->arg(1)->asInt()->evalInt() : 127;
         int sampleoffset = (args->argsCount() >= 3) ? args->arg(2)->asInt()->evalInt() : 0;  
26          int duration = (args->argsCount() >= 4) ? args->arg(3)->asInt()->evalInt() : 0; //TODO: -1 might be a better default value instead of 0          int duration = (args->argsCount() >= 4) ? args->arg(3)->asInt()->evalInt() : 0; //TODO: -1 might be a better default value instead of 0
27    
28          if (note < 0 || note > 127) {          if (note < 0 || note > 127) {
# Line 36  namespace LinuxSampler { Line 35  namespace LinuxSampler {
35              return errorResult(0);              return errorResult(0);
36          }          }
37    
38          if (sampleoffset < 0) {          if (duration < -2) {
39              errMsg("play_note(): argument 3 may not be a negative sample offset");              errMsg("play_note(): argument 4 must be a duration value of at least -2 or higher");
             return errorResult(0);  
         } else if (sampleoffset != 0) {  
             wrnMsg("play_note(): argument 3 does not support a sample offset other than 0 yet");  
         }  
   
         if (duration < -1) {  
             errMsg("play_note(): argument 4 must be a duration value of at least -1 or higher");  
40              return errorResult(0);              return errorResult(0);
41          }          }
42    
# Line 63  namespace LinuxSampler { Line 55  namespace LinuxSampler {
55                  return errorResult(0);                  return errorResult(0);
56              }              }
57              e.Param.Note.ParentNoteID = m_vm->m_event->cause.Param.Note.ID;              e.Param.Note.ParentNoteID = m_vm->m_event->cause.Param.Note.ID;
58                // check if that requested parent note is actually still alive
59                NoteBase* pParentNote =
60                    pEngineChannel->pEngine->NoteByID( e.Param.Note.ParentNoteID );
61                // if parent note is already gone then this new note is not required anymore
62                if (!pParentNote)
63                    return successResult(0);
64          }          }
65    
66          const note_id_t id = pEngineChannel->ScheduleNoteMicroSec(&e, 0);          const note_id_t id = pEngineChannel->ScheduleNoteMicroSec(&e, 0);
67    
68            // if a sample offset is supplied, assign the offset as override
69            // to the previously created Note object
70            if (args->argsCount() >= 3) {
71                int sampleoffset = args->arg(2)->asInt()->evalInt();
72                if (sampleoffset >= 0) {
73                    NoteBase* pNote = pEngineChannel->pEngine->NoteByID(id);
74                    if (pNote) {
75                        pNote->Override.SampleOffset = sampleoffset;
76                    }
77                } else if (sampleoffset < -1) {
78                    errMsg("play_note(): sample offset of argument 3 may not be less than -1");
79                }
80            }
81    
82          // if a duration is supplied (and play-note event was scheduled          // if a duration is supplied (and play-note event was scheduled
83          // successfully above), then schedule a subsequent stop-note event          // successfully above), then schedule a subsequent stop-note event
84          if (id && duration > 0) {          if (id && duration > 0) {
# Line 385  namespace LinuxSampler { Line 397  namespace LinuxSampler {
397              if (!pNote) return successResult();              if (!pNote) return successResult();
398    
399              // if change_vol() was called immediately after note was triggered              // if change_vol() was called immediately after note was triggered
400              // then immediately apply the volume to note object              // then immediately apply the volume to note object, but only if
401              if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {              // change_vol_time() has not been called before
402                if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime &&
403                    pNote->Override.VolumeTime <= DEFAULT_NOTE_VOLUME_TIME_S)
404                {
405                  if (relative)                  if (relative)
406                      pNote->Override.Volume *= fVolumeLin;                      pNote->Override.Volume *= fVolumeLin;
407                  else                  else
# Line 412  namespace LinuxSampler { Line 427  namespace LinuxSampler {
427                  if (!pNote) continue;                  if (!pNote) continue;
428    
429                  // if change_vol() was called immediately after note was triggered                  // if change_vol() was called immediately after note was triggered
430                  // then immediately apply the volume to Note object                  // then immediately apply the volume to Note object, but only if
431                  if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {                  // change_vol_time() has not been called before
432                    if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime &&
433                        pNote->Override.VolumeTime <= DEFAULT_NOTE_VOLUME_TIME_S)
434                    {
435                      if (relative)                      if (relative)
436                          pNote->Override.Volume *= fVolumeLin;                          pNote->Override.Volume *= fVolumeLin;
437                      else                      else
# Line 472  namespace LinuxSampler { Line 490  namespace LinuxSampler {
490              if (!pNote) return successResult();              if (!pNote) return successResult();
491    
492              // if change_tune() was called immediately after note was triggered              // if change_tune() was called immediately after note was triggered
493              // then immediately apply the tuning to Note object              // then immediately apply the tuning to Note object, but only if
494              if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {              // change_tune_time() has not been called before
495                if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime &&
496                    pNote->Override.PitchTime <= DEFAULT_NOTE_PITCH_TIME_S)
497                {
498                  if (relative)                  if (relative)
499                      pNote->Override.Pitch *= fFreqRatio;                      pNote->Override.Pitch *= fFreqRatio;
500                  else                  else
# Line 499  namespace LinuxSampler { Line 520  namespace LinuxSampler {
520                  if (!pNote) continue;                  if (!pNote) continue;
521    
522                  // if change_tune() was called immediately after note was triggered                  // if change_tune() was called immediately after note was triggered
523                  // then immediately apply the tuning to Note object                  // then immediately apply the tuning to Note object, but only if
524                  if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {                  // change_tune_time() has not been called before
525                    if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime &&
526                        pNote->Override.PitchTime <= DEFAULT_NOTE_PITCH_TIME_S)
527                    {
528                      if (relative)                      if (relative)
529                          pNote->Override.Pitch *= fFreqRatio;                          pNote->Override.Pitch *= fFreqRatio;
530                      else                      else
# Line 814  namespace LinuxSampler { Line 838  namespace LinuxSampler {
838    
839      VMFnResult* InstrumentScriptVMFunction_change_attack::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_attack::exec(VMFnArgs* args) {
840          int attack = args->arg(1)->asInt()->evalInt();          int attack = args->arg(1)->asInt()->evalInt();
841          if (attack > VM_EG_PAR_MAX_VALUE) {          // note: intentionally not checking against a max. value here!
842              wrnMsg("change_attack(): argument 2 may not be larger than 1000000");          // (to allow i.e. passing 2000000 for doubling the attack time)
843              attack = VM_EG_PAR_MAX_VALUE;          if (attack < 0) {
         } else if (attack < 0) {  
844              wrnMsg("change_attack(): argument 2 may not be negative");              wrnMsg("change_attack(): argument 2 may not be negative");
845              attack = 0;              attack = 0;
846          }          }
# Line 901  namespace LinuxSampler { Line 924  namespace LinuxSampler {
924    
925      VMFnResult* InstrumentScriptVMFunction_change_decay::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_decay::exec(VMFnArgs* args) {
926          int decay = args->arg(1)->asInt()->evalInt();          int decay = args->arg(1)->asInt()->evalInt();
927          if (decay > VM_EG_PAR_MAX_VALUE) {          // note: intentionally not checking against a max. value here!
928              wrnMsg("change_decay(): argument 2 may not be larger than 1000000");          // (to allow i.e. passing 2000000 for doubling the decay time)
929              decay = VM_EG_PAR_MAX_VALUE;          if (decay < 0) {
         } else if (decay < 0) {  
930              wrnMsg("change_decay(): argument 2 may not be negative");              wrnMsg("change_decay(): argument 2 may not be negative");
931              decay = 0;              decay = 0;
932          }          }
# Line 988  namespace LinuxSampler { Line 1010  namespace LinuxSampler {
1010    
1011      VMFnResult* InstrumentScriptVMFunction_change_release::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_release::exec(VMFnArgs* args) {
1012          int release = args->arg(1)->asInt()->evalInt();          int release = args->arg(1)->asInt()->evalInt();
1013          if (release > VM_EG_PAR_MAX_VALUE) {          // note: intentionally not checking against a max. value here!
1014              wrnMsg("change_release(): argument 2 may not be larger than 1000000");          // (to allow i.e. passing 2000000 for doubling the release time)
1015              release = VM_EG_PAR_MAX_VALUE;          if (release < 0) {
         } else if (release < 0) {  
1016              wrnMsg("change_release(): argument 2 may not be negative");              wrnMsg("change_release(): argument 2 may not be negative");
1017              release = 0;              release = 0;
1018          }          }
# Line 1059  namespace LinuxSampler { Line 1080  namespace LinuxSampler {
1080          return successResult();          return successResult();
1081      }      }
1082    
1083        // template for change_*() functions
1084    
1085      bool VMChangeSynthParamFunction::acceptsArgType(int iArg, ExprType_t type) const {      bool VMChangeSynthParamFunction::acceptsArgType(int iArg, ExprType_t type) const {
1086          if (iArg == 0)          if (iArg == 0)
1087              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
# Line 1151  namespace LinuxSampler { Line 1174  namespace LinuxSampler {
1174          return successResult();          return successResult();
1175      }      }
1176    
1177        // change_sustain() function
1178    
1179        VMFnResult* InstrumentScriptVMFunction_change_sustain::exec(VMFnArgs* args) {
1180            return VMChangeSynthParamFunction::execTemplate<
1181            &NoteBase::_Override::Sustain,
1182            Event::synth_param_sustain,
1183            true, NO_LIMIT, 0>( args, "change_sustain" );
1184        }
1185    
1186      // change_amp_lfo_depth() function      // change_amp_lfo_depth() function
1187    
1188      VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_depth::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_depth::exec(VMFnArgs* args) {
# Line 1205  namespace LinuxSampler { Line 1237  namespace LinuxSampler {
1237                      false, NO_LIMIT, 0>( args, "change_tune_time" );                      false, NO_LIMIT, 0>( args, "change_tune_time" );
1238      }      }
1239    
1240        // template for change_*_curve() functions
1241    
1242        bool VMChangeFadeCurveFunction::acceptsArgType(int iArg, ExprType_t type) const {
1243            if (iArg == 0)
1244                return type == INT_EXPR || type == INT_ARR_EXPR;
1245            else
1246                return type == INT_EXPR;
1247        }
1248    
1249        template<fade_curve_t NoteBase::_Override::*T_noteParam, int T_synthParam>
1250        VMFnResult* VMChangeFadeCurveFunction::execTemplate(VMFnArgs* args, const char* functionName) {
1251            int value = args->arg(1)->asInt()->evalInt();
1252            switch (value) {
1253                case FADE_CURVE_LINEAR:
1254                case FADE_CURVE_EASE_IN_EASE_OUT:
1255                    break;
1256                default:
1257                    wrnMsg(String(functionName) + "(): invalid curve type passed as argument 2");
1258                    return successResult();
1259            }
1260    
1261            AbstractEngineChannel* pEngineChannel =
1262                static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
1263    
1264            if (args->arg(0)->exprType() == INT_EXPR) {
1265                const ScriptID id = args->arg(0)->asInt()->evalInt();
1266                if (!id) {
1267                    wrnMsg(String(functionName) + "(): note ID for argument 1 may not be zero");
1268                    return successResult();
1269                }
1270                if (!id.isNoteID()) {
1271                    wrnMsg(String(functionName) + "(): argument 1 is not a note ID");
1272                    return successResult();
1273                }
1274    
1275                NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() );
1276                if (!pNote) return successResult();
1277    
1278                // if this change_*_curve() script function was called immediately after
1279                // note was triggered then immediately apply the synth parameter
1280                // change to Note object
1281                if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {
1282                    pNote->Override.*T_noteParam = (fade_curve_t) value;
1283                } else { // otherwise schedule this synth parameter change ...
1284                    Event e = m_vm->m_event->cause; // copy to get fragment time for "now"
1285                    e.Init(); // clear IDs
1286                    e.Type = Event::type_note_synth_param;
1287                    e.Param.NoteSynthParam.NoteID   = id.noteID();
1288                    e.Param.NoteSynthParam.Type     = (Event::synth_param_t) T_synthParam;
1289                    e.Param.NoteSynthParam.Delta    = value;
1290                    e.Param.NoteSynthParam.Relative = false;
1291    
1292                    pEngineChannel->ScheduleEventMicroSec(&e, 0);
1293                }
1294            } else if (args->arg(0)->exprType() == INT_ARR_EXPR) {
1295                VMIntArrayExpr* ids = args->arg(0)->asIntArray();
1296                for (int i = 0; i < ids->arraySize(); ++i) {
1297                    const ScriptID id = ids->evalIntElement(i);
1298                    if (!id || !id.isNoteID()) continue;
1299    
1300                    NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() );
1301                    if (!pNote) continue;
1302    
1303                    // if this change_*_curve() script function was called immediately after
1304                    // note was triggered then immediately apply the synth parameter
1305                    // change to Note object
1306                    if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {
1307                        pNote->Override.*T_noteParam = (fade_curve_t) value;
1308                    } else { // otherwise schedule this synth parameter change ...
1309                        Event e = m_vm->m_event->cause; // copy to get fragment time for "now"
1310                        e.Init(); // clear IDs
1311                        e.Type = Event::type_note_synth_param;
1312                        e.Param.NoteSynthParam.NoteID   = id.noteID();
1313                        e.Param.NoteSynthParam.Type     = (Event::synth_param_t) T_synthParam;
1314                        e.Param.NoteSynthParam.Delta    = value;
1315                        e.Param.NoteSynthParam.Relative = false;
1316    
1317                        pEngineChannel->ScheduleEventMicroSec(&e, 0);
1318                    }
1319                }
1320            }
1321    
1322            return successResult();
1323        }
1324    
1325        // change_vol_curve() function
1326    
1327        VMFnResult* InstrumentScriptVMFunction_change_vol_curve::exec(VMFnArgs* args) {
1328            return VMChangeFadeCurveFunction::execTemplate<
1329                        &NoteBase::_Override::VolumeCurve,
1330                        Event::synth_param_volume_curve>( args, "change_vol_curve" );
1331        }
1332    
1333        // change_tune_curve() function
1334    
1335        VMFnResult* InstrumentScriptVMFunction_change_tune_curve::exec(VMFnArgs* args) {
1336            return VMChangeFadeCurveFunction::execTemplate<
1337                        &NoteBase::_Override::PitchCurve,
1338                        Event::synth_param_pitch_curve>( args, "change_tune_curve" );
1339        }
1340    
1341      // fade_in() function      // fade_in() function
1342    
1343      InstrumentScriptVMFunction_fade_in::InstrumentScriptVMFunction_fade_in(InstrumentScriptVM* parent)      InstrumentScriptVMFunction_fade_in::InstrumentScriptVMFunction_fade_in(InstrumentScriptVM* parent)
# Line 1631  namespace LinuxSampler { Line 1764  namespace LinuxSampler {
1764          if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {          if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {
1765              pNote->cause.Param.Note.Key = value;              pNote->cause.Param.Note.Key = value;
1766              m_vm->m_event->cause.Param.Note.Key = value;              m_vm->m_event->cause.Param.Note.Key = value;
1767          } else {          } else {
1768              wrnMsg("change_note(): note number can only be changed when note is new");              wrnMsg("change_note(): note number can only be changed when note is new");
1769          }          }
1770    
# Line 1671  namespace LinuxSampler { Line 1804  namespace LinuxSampler {
1804          if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {          if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {
1805              pNote->cause.Param.Note.Velocity = value;              pNote->cause.Param.Note.Velocity = value;
1806              m_vm->m_event->cause.Param.Note.Velocity = value;              m_vm->m_event->cause.Param.Note.Velocity = value;
1807          } else {          } else {
1808              wrnMsg("change_velo(): velocity can only be changed when note is new");              wrnMsg("change_velo(): velocity can only be changed when note is new");
1809          }          }
1810    
1811          return successResult();          return successResult();
1812      }      }
1813    
1814        // change_play_pos() function
1815    
1816        InstrumentScriptVMFunction_change_play_pos::InstrumentScriptVMFunction_change_play_pos(InstrumentScriptVM* parent)
1817        : m_vm(parent)
1818        {
1819        }
1820    
1821        VMFnResult* InstrumentScriptVMFunction_change_play_pos::exec(VMFnArgs* args) {
1822            const ScriptID id = args->arg(0)->asInt()->evalInt();
1823            if (!id) {
1824                wrnMsg("change_play_pos(): note ID for argument 1 may not be zero");
1825                return successResult();
1826            }
1827            if (!id.isNoteID()) {
1828                wrnMsg("change_play_pos(): argument 1 is not a note ID");
1829                return successResult();
1830            }
1831    
1832            const int pos = args->arg(1)->asInt()->evalInt();
1833            if (pos < 0) {
1834                wrnMsg("change_play_pos(): playback position of argument 2 may not be negative");
1835                return successResult();
1836            }
1837    
1838            AbstractEngineChannel* pEngineChannel =
1839                static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
1840    
1841            NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() );
1842            if (!pNote) return successResult();
1843    
1844            pNote->Override.SampleOffset = pos;
1845    
1846            return successResult();
1847        }
1848    
1849      // event_status() function      // event_status() function
1850    
1851      InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent)      InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent)
# Line 1703  namespace LinuxSampler { Line 1871  namespace LinuxSampler {
1871          return successResult(pNote ? EVENT_STATUS_NOTE_QUEUE : EVENT_STATUS_INACTIVE);          return successResult(pNote ? EVENT_STATUS_NOTE_QUEUE : EVENT_STATUS_INACTIVE);
1872      }      }
1873    
1874        // callback_status() function
1875    
1876        InstrumentScriptVMFunction_callback_status::InstrumentScriptVMFunction_callback_status(InstrumentScriptVM* parent)
1877            : m_vm(parent)
1878        {
1879        }
1880    
1881        VMFnResult* InstrumentScriptVMFunction_callback_status::exec(VMFnArgs* args) {
1882            const script_callback_id_t id = args->arg(0)->asInt()->evalInt();
1883            if (!id) {
1884                wrnMsg("callback_status(): callback ID for argument 1 may not be zero");
1885                return successResult();
1886            }
1887    
1888            AbstractEngineChannel* pEngineChannel =
1889                static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
1890    
1891            RTList<ScriptEvent>::Iterator itCallback = pEngineChannel->ScriptCallbackByID(id);
1892            if (!itCallback)
1893                return successResult(CALLBACK_STATUS_TERMINATED);
1894    
1895            return successResult(
1896                (m_vm->m_event->execCtx == itCallback->execCtx) ?
1897                    CALLBACK_STATUS_RUNNING : CALLBACK_STATUS_QUEUE
1898            );
1899        }
1900    
1901      // wait() function (overrides core wait() implementation)      // wait() function (overrides core wait() implementation)
1902    
1903      InstrumentScriptVMFunction_wait::InstrumentScriptVMFunction_wait(InstrumentScriptVM* parent)      InstrumentScriptVMFunction_wait::InstrumentScriptVMFunction_wait(InstrumentScriptVM* parent)
# Line 1749  namespace LinuxSampler { Line 1944  namespace LinuxSampler {
1944          return successResult();          return successResult();
1945      }      }
1946    
1947        // abort() function
1948    
1949        InstrumentScriptVMFunction_abort::InstrumentScriptVMFunction_abort(InstrumentScriptVM* parent)
1950            : m_vm(parent)
1951        {
1952        }
1953    
1954        VMFnResult* InstrumentScriptVMFunction_abort::exec(VMFnArgs* args) {
1955            const script_callback_id_t id = args->arg(0)->asInt()->evalInt();
1956            if (!id) {
1957                wrnMsg("abort(): callback ID for argument 1 may not be zero");
1958                return successResult();
1959            }
1960    
1961            AbstractEngineChannel* pEngineChannel =
1962                static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
1963    
1964            RTList<ScriptEvent>::Iterator itCallback = pEngineChannel->ScriptCallbackByID(id);
1965            if (!itCallback) return successResult(); // ignore if callback is i.e. not alive anymore
1966    
1967            itCallback->execCtx->signalAbort();
1968    
1969            return successResult();
1970        }
1971    
1972        // fork() function
1973    
1974        InstrumentScriptVMFunction_fork::InstrumentScriptVMFunction_fork(InstrumentScriptVM* parent)
1975            : m_vm(parent)
1976        {
1977        }
1978    
1979        VMFnResult* InstrumentScriptVMFunction_fork::exec(VMFnArgs* args) {
1980            // check if this is actually the parent going to fork, or rather one of
1981            // the children which is already forked
1982            if (m_vm->m_event->forkIndex != 0) { // this is the entry point for a child ...
1983                int forkResult = m_vm->m_event->forkIndex;
1984                // reset so that this child may i.e. also call fork() later on
1985                m_vm->m_event->forkIndex = 0;
1986                return successResult(forkResult);
1987            }
1988    
1989            // if we are here, then this is the parent, so we must fork this parent
1990    
1991            const int n =
1992                (args->argsCount() >= 1) ? args->arg(0)->asInt()->evalInt() : 1;
1993            const bool bAutoAbort =
1994                (args->argsCount() >= 2) ? args->arg(1)->asInt()->evalInt() : true;
1995    
1996            if (m_vm->m_event->countChildHandlers() + n > MAX_FORK_PER_SCRIPT_HANDLER) {
1997                wrnMsg("fork(): requested amount would exceed allowed limit per event handler");
1998                return successResult(-1);
1999            }
2000    
2001            AbstractEngineChannel* pEngineChannel =
2002                static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
2003    
2004            if (!pEngineChannel->hasFreeScriptCallbacks(n)) {
2005                wrnMsg("fork(): global limit of event handlers exceeded");
2006                return successResult(-1);
2007            }
2008    
2009            for (int iChild = 0; iChild < n; ++iChild) {
2010                RTList<ScriptEvent>::Iterator itChild =
2011                    pEngineChannel->forkScriptCallback(m_vm->m_event, bAutoAbort);
2012                if (!itChild) { // should never happen, otherwise its a bug ...
2013                    errMsg("fork(): internal error while allocating child");
2014                    return errorResult(-1); // terminate script
2015                }
2016                // since both parent, as well all child script execution instances
2017                // all land in this exect() method, the following is (more or less)
2018                // the only feature that lets us distinguish the parent and
2019                // respective children from each other in this exect() method
2020                itChild->forkIndex = iChild + 1;
2021            }
2022    
2023            return successResult(0);
2024        }
2025    
2026  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.3214  
changed lines
  Added in v.3317

  ViewVC Help
Powered by ViewVC