Browse Source

cmMidiFile.c : Fixed problem where cmMidiFileInsertMsg() did not set d0, and d1.

master
kevin 8 years ago
parent
commit
67fe7fb2be
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      cmMidiFile.c

+ 7
- 2
cmMidiFile.c View File

@@ -1202,7 +1202,9 @@ cmMfRC_t cmMidiFileInsertMsg( cmMidiFileH_t h, unsigned uid, int dtick, cmMidiBy
1202 1202
   else // if dtick is negative ...
1203 1203
   {
1204 1204
     // ... get get the msg before the ref. msg.
1205
-    if((ref = _cmMidiFileMsgBeforeUid(mfp,uid)) == NULL )
1205
+    if((ref = _cmMidiFileMsgBeforeUid(mfp,uid)) != NULL )
1206
+      trkIdx = ref->trkIdx;
1207
+    else
1206 1208
     {
1207 1209
       // ... the ref. msg was first in the track so there is no msg before it
1208 1210
       trkIdx = _cmMidiFileIsMsgFirstOnTrack(mfp,uid);
@@ -1218,7 +1220,10 @@ cmMfRC_t cmMidiFileInsertMsg( cmMidiFileH_t h, unsigned uid, int dtick, cmMidiBy
1218 1220
   // complete the msg setup
1219 1221
   _cmMidiTrack_t* trk   = mfp->trkV + trkIdx;
1220 1222
   cmMidiTrackMsg_t* m   = _cmMidiFileAllocMsg(mfp, trkIdx, abs(dtick), status );
1221
-  cmMidiChMsg_t*    c   = (cmMidiChMsg_t*)m->u.chMsgPtr; // cast away const
1223
+  cmMidiChMsg_t*    c   = (cmMidiChMsg_t*)_cmMidiFileMalloc(mfp,sizeof(cmMidiChMsg_t));
1224
+
1225
+  m->u.chMsgPtr = c;
1226
+  
1222 1227
   c->ch   = ch;
1223 1228
   c->d0   = d0;
1224 1229
   c->d1   = d1;

Loading…
Cancel
Save