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

Diff of /linuxsampler/trunk/src/engines/AbstractEngineChannel.cpp

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

revision 3292 by schoenebeck, Wed May 24 20:05:38 2017 UTC revision 3293 by schoenebeck, Tue Jun 27 22:19:19 2017 UTC
# Line 5  Line 5 
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-2012 Christian Schoenebeck and Grigor Iliev        *   *   Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev        *
8   *   Copyright (C) 2012-2016 Christian Schoenebeck and Andreas Persson     *   *   Copyright (C) 2012-2017 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  *
# Line 984  namespace LinuxSampler { Line 984  namespace LinuxSampler {
984          pScript->suspendedEvents.insert(*pCallback);          pScript->suspendedEvents.insert(*pCallback);
985      }      }
986    
987        /** @brief Fork the given script execution instance.
988         *
989         * Called by real-time instrument script function fork() to create a new
990         * script execution instance (child) of the script execution instance
991         * (parent) that was calling fork(). This is essentially like creating a
992         * new thread for a script handler being executing. The entire execution
993         * state of parent is copied to the "forked" child.
994         *
995         * @param parent - original active script callback instance from which the
996         *                 new child shall be forked from
997         * @param bAutoAbort - whether the forked child shall automatically be
998         *                     terminated as soon as parent terminates
999         * @returns forked new child execution instance
1000         */
1001        RTList<ScriptEvent>::Iterator AbstractEngineChannel::forkScriptCallback(ScriptEvent* parent, bool bAutoAbort) {
1002            // check if the max. amount of child forks for this parent event handler
1003            // instance have not been exceeded yet
1004            if (parent->countChildHandlers() >= MAX_FORK_PER_SCRIPT_HANDLER)
1005                return RTList<ScriptEvent>::Iterator();
1006    
1007            // allocate a new script callback instance for child to be forked
1008            RTList<ScriptEvent>::Iterator itChild = pScript->pEvents->allocAppend();
1009            if (!itChild) return itChild;
1010    
1011            // copy entire script handler state from parent to forked child
1012            parent->forkTo(&*itChild, bAutoAbort);
1013    
1014            // stick the parent ID and child ID respectively to each other
1015            itChild->parentHandlerID = GetScriptCallbackID(parent);
1016            parent->addChildHandlerID( GetScriptCallbackID(&*itChild) );
1017    
1018            // insert newly created (forked) child event handler instance to the
1019            // scheduler queue for being executed soon
1020            pEngine->pEventGenerator->scheduleAheadMicroSec(
1021                pScript->suspendedEvents, // scheduler queue
1022                *itChild, // script event
1023                parent->cause.FragmentPos(), // current time of script event (basis for its next execution)
1024                0 // "resume" new child script callback instance ASAP
1025            );
1026    
1027            return itChild;
1028        }
1029    
1030      FxSend* AbstractEngineChannel::AddFxSend(uint8_t MidiCtrl, String Name) throw (Exception) {      FxSend* AbstractEngineChannel::AddFxSend(uint8_t MidiCtrl, String Name) throw (Exception) {
1031          if (pEngine) pEngine->DisableAndLock();          if (pEngine) pEngine->DisableAndLock();
1032          FxSend* pFxSend = new FxSend(this, MidiCtrl, Name);          FxSend* pFxSend = new FxSend(this, MidiCtrl, Name);

Legend:
Removed from v.3292  
changed lines
  Added in v.3293

  ViewVC Help
Powered by ViewVC