789 |
return successResult(pNote ? EVENT_STATUS_NOTE_QUEUE : EVENT_STATUS_INACTIVE); |
return successResult(pNote ? EVENT_STATUS_NOTE_QUEUE : EVENT_STATUS_INACTIVE); |
790 |
} |
} |
791 |
|
|
792 |
|
// wait() function (overrides core wait() implementation) |
793 |
|
|
794 |
|
InstrumentScriptVMFunction_wait::InstrumentScriptVMFunction_wait(InstrumentScriptVM* parent) |
795 |
|
: CoreVMFunction_wait(parent) |
796 |
|
{ |
797 |
|
} |
798 |
|
|
799 |
|
VMFnResult* InstrumentScriptVMFunction_wait::exec(VMFnArgs* args) { |
800 |
|
InstrumentScriptVM* m_vm = (InstrumentScriptVM*) vm; |
801 |
|
|
802 |
|
// this might be set by passing 1 with the 2nd argument of built-in stop_wait() function |
803 |
|
if (m_vm->m_event->ignoreAllWaitCalls) return successResult(); |
804 |
|
|
805 |
|
return CoreVMFunction_wait::exec(args); |
806 |
|
} |
807 |
|
|
808 |
|
// stop_wait() function |
809 |
|
|
810 |
|
InstrumentScriptVMFunction_stop_wait::InstrumentScriptVMFunction_stop_wait(InstrumentScriptVM* parent) |
811 |
|
: m_vm(parent) |
812 |
|
{ |
813 |
|
} |
814 |
|
|
815 |
|
VMFnResult* InstrumentScriptVMFunction_stop_wait::exec(VMFnArgs* args) { |
816 |
|
AbstractEngineChannel* pEngineChannel = |
817 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
818 |
|
|
819 |
|
const script_callback_id_t id = args->arg(0)->asInt()->evalInt(); |
820 |
|
if (!id) { |
821 |
|
wrnMsg("stop_wait(): callback ID for argument 1 may not be zero"); |
822 |
|
return successResult(); |
823 |
|
} |
824 |
|
|
825 |
|
RTList<ScriptEvent>::Iterator itCallback = pEngineChannel->ScriptCallbackByID(id); |
826 |
|
if (!itCallback) return successResult(); // ignore if callback is i.e. not alive anymore |
827 |
|
|
828 |
|
const bool disableWaitForever = |
829 |
|
(args->argsCount() >= 2) ? (args->arg(1)->asInt()->evalInt() == 1) : false; |
830 |
|
|
831 |
|
pEngineChannel->ScheduleResumeOfScriptCallback( |
832 |
|
itCallback, m_vm->m_event->cause.SchedTime(), disableWaitForever |
833 |
|
); |
834 |
|
|
835 |
|
return successResult(); |
836 |
|
} |
837 |
|
|
838 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |