diff --git a/cwIo.cpp b/cwIo.cpp index 57aeb19..e0977eb 100644 --- a/cwIo.cpp +++ b/cwIo.cpp @@ -55,6 +55,7 @@ namespace cw bool startedFl; char* label; unsigned id; + unsigned index; unsigned periodMicroSec; bool asyncFl; } timer_t; @@ -298,6 +299,7 @@ namespace cw timer_msg_t tm; tm.id = t->id; + tm.index = t->index; m.tid = kTimerTId; m.u.timer = &tm; @@ -312,12 +314,14 @@ namespace cw { rc_t rc = kOkRC; timer_t* t = nullptr; + unsigned timer_idx = kInvalidIdx; // look for a deleted timer for(unsigned i=0; itimerN; ++i) if( p->timerA[i].deletedFl ) { t = p->timerA + i; + timer_idx = i; break; } @@ -331,6 +335,7 @@ namespace cw // keep a pointer to the empty slot t = tA + p->timerN; + timer_idx = p->timerN; // update the timer array mem::release( p->timerA ); @@ -343,6 +348,7 @@ namespace cw t->io = p; t->label = mem::duplStr(label); t->id = id; + t->index = timer_idx; t->asyncFl = asyncFl; t->periodMicroSec = periodMicroSec; @@ -594,7 +600,7 @@ namespace cw m.u.midi = &mm; if((rc = _ioCallback( p, p->midiAsyncFl, &m )) !=kOkRC ) - cwLogError(rc,"MIDI app callback failed."); + cwLogError(rc,"MIDI app callback failed: async fl:%i",p->midiAsyncFl); /* for(unsigned j=0; jmsgCnt; ++j) diff --git a/cwIo.h b/cwIo.h index 204fb96..e0ebae7 100644 --- a/cwIo.h +++ b/cwIo.h @@ -47,7 +47,8 @@ namespace cw typedef struct timer_msg_str { - unsigned id; + unsigned id; // timer id (as set in create) + unsigned index; // timer index as used by timer accessor functions } timer_msg_t; typedef struct serial_msg_str