--- linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.cpp 2017/05/30 15:43:39 3255 +++ linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.cpp 2017/06/05 18:40:18 3277 @@ -1911,4 +1911,29 @@ return successResult(); } + // abort() function + + InstrumentScriptVMFunction_abort::InstrumentScriptVMFunction_abort(InstrumentScriptVM* parent) + : m_vm(parent) + { + } + + VMFnResult* InstrumentScriptVMFunction_abort::exec(VMFnArgs* args) { + const script_callback_id_t id = args->arg(0)->asInt()->evalInt(); + if (!id) { + wrnMsg("abort(): callback ID for argument 1 may not be zero"); + return successResult(); + } + + AbstractEngineChannel* pEngineChannel = + static_cast(m_vm->m_event->cause.pEngineChannel); + + RTList::Iterator itCallback = pEngineChannel->ScriptCallbackByID(id); + if (!itCallback) return successResult(); // ignore if callback is i.e. not alive anymore + + itCallback->execCtx->signalAbort(); + + return successResult(); + } + } // namespace LinuxSampler