Browse Source

cmTimeLine.h/c: Added 'bar' and 'sectionStr' to cmTlMarker_t.

master
kpl 11 years ago
parent
commit
869d1c716b
2 changed files with 28 additions and 13 deletions
  1. 24
    11
      app/cmTimeLine.c
  2. 4
    2
      app/cmTimeLine.h

+ 24
- 11
app/cmTimeLine.c View File

774
   return rc;
774
   return rc;
775
 }
775
 }
776
 
776
 
777
-cmTlRC_t _cmTlAllocMarkerRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmChar_t* refIdStr, int begSmpIdx, unsigned durSmpCnt, unsigned seqId, const cmChar_t* text )
777
+cmTlRC_t _cmTlAllocMarkerRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmChar_t* refIdStr, int begSmpIdx, unsigned durSmpCnt, unsigned seqId, const cmChar_t* text, unsigned bar, const cmChar_t* sectionStr )
778
 {
778
 {
779
-  cmTlRC_t      rc = kOkTlRC;
780
-  _cmTlObj_t*   op = NULL;
781
-  const cmChar_t* textStr = text==NULL ? "" : text;
779
+  cmTlRC_t        rc      = kOkTlRC;
780
+  _cmTlObj_t*     op      = NULL;
781
+  const cmChar_t* textStr = text==NULL       ? "" : text;
782
+  const cmChar_t* sectStr = sectionStr==NULL ? "" : sectionStr;
782
 
783
 
783
   // add memory at the end of the the cmTlMarker_t record to hold the text string.
784
   // add memory at the end of the the cmTlMarker_t record to hold the text string.
784
-  unsigned recdByteCnt = sizeof(cmTlMarker_t) + strlen(textStr) + 1;
785
+  unsigned recdByteCnt = sizeof(cmTlMarker_t) + strlen(textStr) + sizeof(bar) + strlen(sectStr) + 2;
786
+
785
 
787
 
786
   if((rc = _cmTlAllocRecd(p,nameStr,refIdStr,begSmpIdx,durSmpCnt,kMarkerTlId,seqId,recdByteCnt,&op)) != kOkTlRC )
788
   if((rc = _cmTlAllocRecd(p,nameStr,refIdStr,begSmpIdx,durSmpCnt,kMarkerTlId,seqId,recdByteCnt,&op)) != kOkTlRC )
787
     goto errLabel;
789
     goto errLabel;
788
 
790
 
789
   assert(op != NULL);
791
   assert(op != NULL);
790
 
792
 
793
+  // get a ptr to the marker part of the object 
791
   cmTlMarker_t* mp = _cmTimeLineMarkerObjPtr(p,op->obj);
794
   cmTlMarker_t* mp = _cmTimeLineMarkerObjPtr(p,op->obj);
792
 
795
 
793
   assert(mp != NULL );
796
   assert(mp != NULL );
795
   // copy the marker text string into the memory just past the cmTlMarker_t recd.
798
   // copy the marker text string into the memory just past the cmTlMarker_t recd.
796
   cmChar_t* tp = (cmChar_t*)(mp + 1);
799
   cmChar_t* tp = (cmChar_t*)(mp + 1);
797
   strcpy(tp,textStr);
800
   strcpy(tp,textStr);
801
+  
802
+  // copy the section label string into memory just past the markers text string
803
+  cmChar_t* sp = strlen(tp) + 1;
804
+  strcpy(sp,sectStr);
798
 
805
 
799
-  mp->text = tp;
800
-  op->obj->text = tp;
806
+  mp->text       = tp;
807
+  mp->sectionStr = sp;
808
+  mp->bar        = bar;
809
+  op->obj->text  = tp;
801
 
810
 
802
   // notify listeners
811
   // notify listeners
803
   //_cmTlNotifyListener(p, kInsertMsgTlId, op );
812
   //_cmTlNotifyListener(p, kInsertMsgTlId, op );
843
   return rc;
852
   return rc;
844
 }
853
 }
845
 
854
 
846
-cmTlRC_t _cmTlAllocRecdFromJson(_cmTl_t* p,const cmChar_t* nameStr, const cmChar_t* typeIdStr,const cmChar_t* refIdStr, int begSmpIdx, unsigned durSmpCnt, unsigned seqId, const cmChar_t* textStr)
855
+cmTlRC_t _cmTlAllocRecdFromJson(_cmTl_t* p,const cmChar_t* nameStr, const cmChar_t* typeIdStr,const cmChar_t* refIdStr, int begSmpIdx, unsigned durSmpCnt, unsigned seqId, const cmChar_t* textStr, unsigned bar, const cmChar_t* sectionStr)
847
 {
856
 {
848
   cmTlRC_t   rc    = kOkTlRC;
857
   cmTlRC_t   rc    = kOkTlRC;
849
   unsigned   typeId = _cmTlIdLabelToId(p,typeIdStr);
858
   unsigned   typeId = _cmTlIdLabelToId(p,typeIdStr);
852
   {
861
   {
853
     case kAudioFileTlId: rc = _cmTlAllocAudioFileRecd(p,nameStr,refIdStr,begSmpIdx,          seqId,textStr); break;
862
     case kAudioFileTlId: rc = _cmTlAllocAudioFileRecd(p,nameStr,refIdStr,begSmpIdx,          seqId,textStr); break;
854
     case kMidiFileTlId:  rc = _cmTlAllocMidiFileRecd( p,nameStr,refIdStr,begSmpIdx,          seqId,textStr); break;
863
     case kMidiFileTlId:  rc = _cmTlAllocMidiFileRecd( p,nameStr,refIdStr,begSmpIdx,          seqId,textStr); break;
855
-    case kMarkerTlId:    rc = _cmTlAllocMarkerRecd(   p,nameStr,refIdStr,begSmpIdx,durSmpCnt,seqId,textStr); break;
864
+    case kMarkerTlId:    rc = _cmTlAllocMarkerRecd(   p,nameStr,refIdStr,begSmpIdx,durSmpCnt,seqId,textStr,bar,sectionStr); break;
856
     case kAudioEvtTlId:  rc = _cmTlAllocAudioEvtRecd( p,nameStr,refIdStr,begSmpIdx,durSmpCnt,seqId,textStr); break;
865
     case kAudioEvtTlId:  rc = _cmTlAllocAudioEvtRecd( p,nameStr,refIdStr,begSmpIdx,durSmpCnt,seqId,textStr); break;
857
     default:
866
     default:
858
       rc = cmErrMsg(&p->err,kParseFailTlRC,"'%s' is not a valid 'objArray' record type.",cmStringNullGuard(typeIdStr));
867
       rc = cmErrMsg(&p->err,kParseFailTlRC,"'%s' is not a valid 'objArray' record type.",cmStringNullGuard(typeIdStr));
1146
 {
1155
 {
1147
   _cmTl_t* p = _cmTlHandleToPtr(h);
1156
   _cmTl_t* p = _cmTlHandleToPtr(h);
1148
   
1157
   
1149
-  return _cmTlAllocRecdFromJson(p, nameStr, _cmTlIdToLabel(p,typeId), refObjNameStr, begSmpIdx, durSmpCnt, seqId, fn); 
1158
+  return _cmTlAllocRecdFromJson(p, nameStr, _cmTlIdToLabel(p,typeId), refObjNameStr, begSmpIdx, durSmpCnt, seqId, fn, 0, NULL); 
1150
 }
1159
 }
1151
 
1160
 
1152
 cmTlObj_t* _cmTimeLineFindFile( _cmTl_t* p, const cmChar_t* fn, unsigned typeId )
1161
 cmTlObj_t* _cmTimeLineFindFile( _cmTl_t* p, const cmChar_t* fn, unsigned typeId )
1356
     unsigned        durSmpCnt;
1365
     unsigned        durSmpCnt;
1357
     unsigned        seqId;
1366
     unsigned        seqId;
1358
     const cmChar_t* textStr;
1367
     const cmChar_t* textStr;
1368
+    unsigned        bar = 0;
1369
+    const cmChar_t* sectStr = NULL;
1359
 
1370
 
1360
     if( cmJsonMemberValues(rp,&errLabelPtr,
1371
     if( cmJsonMemberValues(rp,&errLabelPtr,
1361
         "label",kStringTId,&nameStr,
1372
         "label",kStringTId,&nameStr,
1365
         "smpCnt",kIntTId,&durSmpCnt,
1376
         "smpCnt",kIntTId,&durSmpCnt,
1366
         "trackId",kIntTId,&seqId,
1377
         "trackId",kIntTId,&seqId,
1367
         "textStr",kStringTId,&textStr,
1378
         "textStr",kStringTId,&textStr,
1379
+        "bar",    kIntTId | kOptArgJsFl,&bar,
1380
+        "sectStr",kStringTId | kOptArgJsFl,&sectStr,
1368
         NULL) != kOkJsRC )
1381
         NULL) != kOkJsRC )
1369
     {
1382
     {
1370
       rc = _cmTlParseErr(&p->err, errLabelPtr, i, ifn );
1383
       rc = _cmTlParseErr(&p->err, errLabelPtr, i, ifn );
1372
     }
1385
     }
1373
 
1386
 
1374
 
1387
 
1375
-    if((rc = _cmTlAllocRecdFromJson(p,nameStr,typeIdStr,refIdStr,begSmpIdx,durSmpCnt,seqId,textStr)) != kOkTlRC )
1388
+    if((rc = _cmTlAllocRecdFromJson(p,nameStr,typeIdStr,refIdStr,begSmpIdx,durSmpCnt,seqId,textStr,bar,sectStr)) != kOkTlRC )
1376
       goto errLabel;
1389
       goto errLabel;
1377
     
1390
     
1378
   }
1391
   }

+ 4
- 2
app/cmTimeLine.h View File

94
 
94
 
95
   typedef struct
95
   typedef struct
96
   {
96
   {
97
-    cmTlObj_t       obj;
98
-    const cmChar_t* text;
97
+    cmTlObj_t        obj;
98
+    const cmChar_t*  text;
99
+    unsigned         bar;
100
+    const cmChar_t*  sectionStr; 
99
   } cmTlMarker_t;
101
   } cmTlMarker_t;
100
 
102
 
101
   extern cmTlH_t cmTimeLineNullHandle;
103
   extern cmTlH_t cmTimeLineNullHandle;

Loading…
Cancel
Save