cwFlow.cpp : maxCycleCnt=0 now means that the init pass should be run but not the runtime pass.

Setting maxCycleCnt to kInvalidCnt now removed cycle count limit.
This commit is contained in:
kevin 2024-05-08 10:24:25 -04:00
parent 4872f9234b
commit 9f1339e517

View File

@ -675,6 +675,7 @@ cw::rc_t cw::flow::create( handle_t& hRef,
bool printClassDictFl = false; bool printClassDictFl = false;
bool printNetworkFl = false; bool printNetworkFl = false;
variable_t* proxyVarL = nullptr; variable_t* proxyVarL = nullptr;
unsigned maxCycleCount = kInvalidCnt;
if(( rc = destroy(hRef)) != kOkRC ) if(( rc = destroy(hRef)) != kOkRC )
return rc; return rc;
@ -708,11 +709,12 @@ cw::rc_t cw::flow::create( handle_t& hRef,
p->framesPerCycle = kDefaultFramesPerCycle; p->framesPerCycle = kDefaultFramesPerCycle;
p->sample_rate = kDefaultSampleRate; p->sample_rate = kDefaultSampleRate;
p->maxCycleCount = kInvalidCnt;
// parse the optional args // parse the optional args
if((rc = flowCfg->getv_opt("framesPerCycle", p->framesPerCycle, if((rc = flowCfg->getv_opt("framesPerCycle", p->framesPerCycle,
"sample_rate", p->sample_rate, "sample_rate", p->sample_rate,
"maxCycleCount", p->maxCycleCount, "maxCycleCount", maxCycleCount,
"multiPriPresetProbFl", p->multiPriPresetProbFl, "multiPriPresetProbFl", p->multiPriPresetProbFl,
"multiSecPresetProbFl", p->multiSecPresetProbFl, "multiSecPresetProbFl", p->multiSecPresetProbFl,
"multiPresetInterpFl", p->multiPresetInterpFl, "multiPresetInterpFl", p->multiPresetInterpFl,
@ -723,6 +725,9 @@ cw::rc_t cw::flow::create( handle_t& hRef,
goto errLabel; goto errLabel;
} }
if( maxCycleCount != kInvalidCnt )
p->maxCycleCount = maxCycleCount;
for(unsigned i=0; i<deviceN; ++i) for(unsigned i=0; i<deviceN; ++i)
if( deviceA[i].typeId == kAudioDevTypeId ) if( deviceA[i].typeId == kAudioDevTypeId )
{ {
@ -750,6 +755,7 @@ cw::rc_t cw::flow::create( handle_t& hRef,
if( printNetworkFl ) if( printNetworkFl )
network_print(p->net); network_print(p->net);
p->isInRuntimeFl = true;
hRef.set(p); hRef.set(p);
errLabel: errLabel:
@ -806,23 +812,21 @@ cw::rc_t cw::flow::exec( handle_t h )
rc_t rc = kOkRC; rc_t rc = kOkRC;
flow_t* p = _handleToPtr(h); flow_t* p = _handleToPtr(h);
while( true ) for(; (p->maxCycleCount==kInvalidCnt || (p->maxCycleCount!=kInvalidCnt && p->cycleIndex < p->maxCycleCount)) && rc == kOkRC; p->cycleIndex++ )
{ {
rc = exec_cycle(p->net); rc = exec_cycle(p->net);
// kEofRC indicates that the network asked to terminate
if( rc == kEofRC ) if( rc == kEofRC )
{ {
rc = kOkRC; rc = kOkRC;
break; break;
} }
p->cycleIndex += 1; }
if( p->maxCycleCount > 0 && p->cycleIndex >= p->maxCycleCount )
{ if( p->maxCycleCount != kInvalidCnt && p->cycleIndex >= p->maxCycleCount )
cwLogInfo("'maxCycleCnt' reached: %i. Shutting down flow.",p->maxCycleCount); cwLogInfo("'maxCycleCnt' reached: %i. Shutting down flow.",p->maxCycleCount);
break;
}
}
return rc; return rc;
} }