From d45d86b8be3865ee7abcf8d14ae18a237eacab3a Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 30 Dec 2023 12:40:33 -0500 Subject: [PATCH] cwIoMidiRecordPlay.cpp : Fix bug in vel_table_disable() where velTableN was not set to 0 when the vel table was released. --- cwIoMidiRecordPlay.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cwIoMidiRecordPlay.cpp b/cwIoMidiRecordPlay.cpp index c4fd333..c22b7ba 100644 --- a/cwIoMidiRecordPlay.cpp +++ b/cwIoMidiRecordPlay.cpp @@ -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 ) { - rc_t rc = kOkRC; - midi_record_play_t* p = _handleToPtr(h); - - if( devIdx != kInvalidIdx ) + rc_t rc = kOkRC; + midi_record_play_t* p = _handleToPtr(h); + unsigned begDevIdx = devIdx==kInvalidIdx ? 0 : devIdx; + 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; - } - - p->midiDevA[devIdx].velTableArray = nullptr; + rc = cwLogError(kInvalidArgRC,"The device index '%i'is invalid.",devIdx); + goto errLabel; } - else + + for(unsigned i=begDevIdx; imidiDevN; ++i) - p->midiDevA[i].velTableArray = nullptr; + mem::release(p->midiDevA[i].velTableArray); + p->midiDevA[i].velTableN = 0; } + errLabel: return rc;