--- linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.cpp 2017/06/27 22:19:19 3293 +++ linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.cpp 2017/07/10 17:45:30 3303 @@ -838,10 +838,9 @@ VMFnResult* InstrumentScriptVMFunction_change_attack::exec(VMFnArgs* args) { int attack = args->arg(1)->asInt()->evalInt(); - if (attack > VM_EG_PAR_MAX_VALUE) { - wrnMsg("change_attack(): argument 2 may not be larger than 1000000"); - attack = VM_EG_PAR_MAX_VALUE; - } else if (attack < 0) { + // note: intentionally not checking against a max. value here! + // (to allow i.e. passing 2000000 for doubling the attack time) + if (attack < 0) { wrnMsg("change_attack(): argument 2 may not be negative"); attack = 0; } @@ -925,10 +924,9 @@ VMFnResult* InstrumentScriptVMFunction_change_decay::exec(VMFnArgs* args) { int decay = args->arg(1)->asInt()->evalInt(); - if (decay > VM_EG_PAR_MAX_VALUE) { - wrnMsg("change_decay(): argument 2 may not be larger than 1000000"); - decay = VM_EG_PAR_MAX_VALUE; - } else if (decay < 0) { + // note: intentionally not checking against a max. value here! + // (to allow i.e. passing 2000000 for doubling the decay time) + if (decay < 0) { wrnMsg("change_decay(): argument 2 may not be negative"); decay = 0; } @@ -1012,10 +1010,9 @@ VMFnResult* InstrumentScriptVMFunction_change_release::exec(VMFnArgs* args) { int release = args->arg(1)->asInt()->evalInt(); - if (release > VM_EG_PAR_MAX_VALUE) { - wrnMsg("change_release(): argument 2 may not be larger than 1000000"); - release = VM_EG_PAR_MAX_VALUE; - } else if (release < 0) { + // note: intentionally not checking against a max. value here! + // (to allow i.e. passing 2000000 for doubling the release time) + if (release < 0) { wrnMsg("change_release(): argument 2 may not be negative"); release = 0; } @@ -1865,6 +1862,33 @@ return successResult(pNote ? EVENT_STATUS_NOTE_QUEUE : EVENT_STATUS_INACTIVE); } + // callback_status() function + + InstrumentScriptVMFunction_callback_status::InstrumentScriptVMFunction_callback_status(InstrumentScriptVM* parent) + : m_vm(parent) + { + } + + VMFnResult* InstrumentScriptVMFunction_callback_status::exec(VMFnArgs* args) { + const script_callback_id_t id = args->arg(0)->asInt()->evalInt(); + if (!id) { + wrnMsg("callback_status(): 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(CALLBACK_STATUS_TERMINATED); + + return successResult( + (m_vm->m_event->execCtx == itCallback->execCtx) ? + CALLBACK_STATUS_RUNNING : CALLBACK_STATUS_QUEUE + ); + } + // wait() function (overrides core wait() implementation) InstrumentScriptVMFunction_wait::InstrumentScriptVMFunction_wait(InstrumentScriptVM* parent)