cwIoMidiRecordPlay.cpp : Fix bug in vel_table_disable() where velTableN was not set to 0 when the vel table was released.

This commit is contained in:
kevin 2023-12-30 12:40:33 -05:00
parent ca53e712a6
commit d45d86b8be

View File

@ -2159,24 +2159,23 @@ unsigned cw::midi_record_play::dev_count( handle_t h )
cw::rc_t cw::midi_record_play::vel_table_disable( handle_t h, unsigned devIdx ) cw::rc_t cw::midi_record_play::vel_table_disable( handle_t h, unsigned devIdx )
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
midi_record_play_t* p = _handleToPtr(h); midi_record_play_t* p = _handleToPtr(h);
unsigned begDevIdx = devIdx==kInvalidIdx ? 0 : devIdx;
if( devIdx != kInvalidIdx ) unsigned endDevIdx = devIdx==kInvalidIdx ? p->midiDevN : begDevIdx+1;
if( devIdx != kInvalidIdx && devIdx > p->midiDevN )
{ {
if( devIdx > p->midiDevN ) rc = cwLogError(kInvalidArgRC,"The device index '%i'is invalid.",devIdx);
{ goto errLabel;
rc = cwLogError(kInvalidArgRC,"The device index '%i'is invalid.",devIdx);
goto errLabel;
}
p->midiDevA[devIdx].velTableArray = nullptr;
} }
else
for(unsigned i=begDevIdx; i<endDevIdx; ++i)
{ {
for(unsigned i=0; i<p->midiDevN; ++i) mem::release(p->midiDevA[i].velTableArray);
p->midiDevA[i].velTableArray = nullptr; p->midiDevA[i].velTableN = 0;
} }
errLabel: errLabel:
return rc; return rc;