Browse Source

cmDevCfg.h/c:Added label to domain specific cfg records.

master
kevin 11 years ago
parent
commit
1be236f8d2
2 changed files with 125 additions and 119 deletions
  1. 117
    114
      cmDevCfg.c
  2. 8
    5
      cmDevCfg.h

+ 117
- 114
cmDevCfg.c View File

@@ -25,10 +25,10 @@ cmDevCfgH_t cmDevCfgNullHandle = cmSTATIC_NULL_HANDLE;
25 25
 
26 26
 typedef struct cmDcmCfg_str
27 27
 {
28
-  cmChar_t*     dcLabelStr;   // the cfg label 
29
-  unsigned      cfgId;        // unique among all cfg's assigned to a loc
30
-  cmTypeDcmId_t typeId;       // the cfg type id (e.g. midi, audio, net, ...)
31
-  cmChar_t*     descStr;      // summary description string 
28
+  cmChar_t*     dcLabelStr;     // the cfg label 
29
+  unsigned      cfgId;          // unique among all cfg's assigned to a loc
30
+  cmTypeDcmId_t typeId;         // the cfg type id (e.g. midi, audio, net, ...)
31
+  cmChar_t*     descStr;        // summary description string 
32 32
 
33 33
   // NOTE: any fields added to this structure, type generic (above) 
34 34
   // or type specific (below), must be explicitely duplicated in cmDevCfgLocStore().
@@ -46,9 +46,9 @@ typedef struct cmDcmCfg_str
46 46
 
47 47
 typedef struct
48 48
 {
49
-  cmTypeDcmId_t tid;      // Type Id for this map or tInvalidDcmTId if the record is not active.
50
-  unsigned      cfgId;    // cfgId of the cfg recd assoc'd with this map
51
-  cmDcmCfg_t*   cfg;      // pointer to the cfg recd assoc'd with this map (cfg->cfgId == cmDcmMap_t.cfgId)
49
+  cmTypeDcmId_t tid;            // Type Id for this map or tInvalidDcmTId if the record is not active.
50
+  unsigned      cfgId;          // cfgId of the cfg recd assoc'd with this map
51
+  cmDcmCfg_t*   cfg;            // pointer to the cfg recd assoc'd with this map (cfg->cfgId == cmDcmMap_t.cfgId)
52 52
 } cmDcmMap_t;
53 53
 
54 54
 typedef struct
@@ -60,10 +60,10 @@ typedef struct
60 60
 
61 61
 typedef struct cmDcmLoc_str
62 62
 {
63
-  cmChar_t*            labelStr;
63
+  cmChar_t* labelStr;
64 64
 
65
-  cmDcmApp_t*          app;
66
-  unsigned             appCnt;
65
+  cmDcmApp_t* app;
66
+  unsigned    appCnt;
67 67
 
68 68
   cmDcmCfg_t*          cfg;
69 69
 
@@ -134,7 +134,7 @@ void _cmDcmDuplAudio( cmDcmAudio_t* d, const cmDcmAudio_t* s )
134 134
 {
135 135
   d->inDevLabelStr  = cmMemAllocStr(s->inDevLabelStr);
136 136
   d->outDevLabelStr = cmMemAllocStr(s->outDevLabelStr);
137
-  d->audioSysArgs   = s->audioSysArgs;
137
+  d->rtSysArgs      = s->rtSysArgs;
138 138
 }
139 139
 
140 140
 void _cmDcmFreeNet( cmDcmNet_t* r )
@@ -155,7 +155,7 @@ void _cmDcmFreeCfg( cmDcm_t* p, cmDcmLoc_t* lp, cmDcmCfg_t* cp )
155 155
 {
156 156
   // unlink the cfg recd
157 157
   if( cp->prev == NULL )
158
-    lp->cfg = cp->next;
158
+    lp->cfg        = cp->next;
159 159
   else
160 160
     cp->prev->next = cp->next;
161 161
   
@@ -184,7 +184,7 @@ void _cmDcmFreeLoc( cmDcm_t* p, cmDcmLoc_t* lp )
184 184
 
185 185
   // unlink the loc recd
186 186
   if( lp->prev == NULL )
187
-    p->loc = lp->next;
187
+    p->loc         = lp->next;
188 188
   else
189 189
     lp->prev->next = lp->next;
190 190
 
@@ -210,7 +210,7 @@ void _cmDcmFreeAllLocs( cmDcm_t* p )
210 210
   while( p->loc != NULL )
211 211
     _cmDcmFreeLoc(p,p->loc);
212 212
   
213
-  p->clp    = NULL;
213
+  p->clp = NULL;
214 214
 }
215 215
 
216 216
 cmDcRC_t _cmDcmFree( cmDcm_t* p )
@@ -226,9 +226,9 @@ cmDcRC_t _cmDcmFree( cmDcm_t* p )
226 226
 
227 227
 cmDcmLoc_t* _cmDcmFindLoc( cmDcm_t* p, const cmChar_t* labelStr )
228 228
 {
229
-  cmDcmLoc_t* lp = p->loc;
229
+  cmDcmLoc_t* lp                      = p->loc;
230 230
   for(; lp!=NULL; lp=lp->next)
231
-    if(strcmp(lp->labelStr,labelStr)==0)
231
+    if(strcmp(lp->labelStr,labelStr) == 0)
232 232
       return lp;
233 233
   return NULL;
234 234
 }
@@ -250,26 +250,26 @@ cmDcRC_t _cmDcmNewLoc( cmDcm_t* p, const cmChar_t* labelStr, cmDcmLoc_t**  locRe
250 250
     return cmErrMsg(&p->err,kDuplLabelDcRC,"The location label '%s' is already in use.",labelStr);
251 251
 
252 252
   // create a new loc recd
253
-  lp  = cmMemAllocZ(cmDcmLoc_t,1);
253
+  lp           = cmMemAllocZ(cmDcmLoc_t,1);
254 254
   lp->labelStr = cmMemAllocStr(labelStr);
255 255
 
256 256
   // if the cur loc is not current set - then prepend loc
257 257
   if( p->clp == NULL )
258 258
   {
259
-    lp->prev = NULL;
260
-    lp->next = p->loc;
259
+    lp->prev       = NULL;
260
+    lp->next       = p->loc;
261 261
     if( p->loc == NULL )
262
-      p->loc = lp;
262
+      p->loc       = lp;
263 263
     else
264 264
       p->loc->prev = lp;    
265 265
   }
266
-  else // otherwise insert loc after the cur loc
266
+  else                          // otherwise insert loc after the cur loc
267 267
   {
268 268
     lp->prev = p->clp;
269
-    lp->next = p->clp->next;
269
+    lp->next             = p->clp->next;
270 270
     if( p->clp->next != NULL )
271 271
       p->clp->next->prev = lp;
272
-    p->clp->next = lp;
272
+    p->clp->next         = lp;
273 273
   }
274 274
 
275 275
   // make the new loc the current loc
@@ -309,7 +309,7 @@ cmDcRC_t _cmDevCfgReadFile( cmDcm_t* p, const cmChar_t* fn )
309 309
 
310 310
 cmDcRC_t cmDevCfgAlloc( cmCtx_t* c, cmDevCfgH_t* hp, const cmChar_t* fn )
311 311
 {
312
-  cmDcRC_t rc;
312
+  cmDcRC_t    rc;
313 313
   cmDcmLoc_t* lp;
314 314
 
315 315
   if((rc = cmDevCfgFree(hp)) != kOkDcRC )
@@ -351,8 +351,8 @@ cmDcRC_t cmDevCfgAlloc( cmCtx_t* c, cmDevCfgH_t* hp, const cmChar_t* fn )
351 351
 
352 352
 cmDcRC_t cmDevCfgFree( cmDevCfgH_t* hp )
353 353
 {
354
-  cmDcRC_t rc = kOkDcRC;
355
-  if( hp == NULL || cmDevCfgIsValid(*hp)==false )
354
+  cmDcRC_t rc                             = kOkDcRC;
355
+  if( hp == NULL || cmDevCfgIsValid(*hp) == false )
356 356
     return rc;
357 357
 
358 358
   cmDcm_t* p = _cmDcmHandleToPtr(*hp);
@@ -370,7 +370,7 @@ bool cmDevCfgIsValid( cmDevCfgH_t h )
370 370
 
371 371
 unsigned cmDevCfgCount( cmDevCfgH_t h, cmTypeDcmId_t typeId )
372 372
 {
373
-  unsigned n=0;
373
+  unsigned n = 0;
374 374
   cmDcm_t* p = _cmDcmHandleToPtr(h);
375 375
 
376 376
   assert( p->clp != NULL);
@@ -384,7 +384,7 @@ unsigned cmDevCfgCount( cmDevCfgH_t h, cmTypeDcmId_t typeId )
384 384
 
385 385
 cmDcmCfg_t* _cmDevCfgIndexToPtr( cmDcm_t* p, cmTypeDcmId_t typeId, unsigned index, bool errFl )
386 386
 {
387
-  unsigned n=0;
387
+  unsigned    n  = 0;
388 388
   assert( p->clp != NULL);
389 389
   cmDcmCfg_t* cp = p->clp->cfg;
390 390
   for(; cp!= NULL; cp=cp->next)
@@ -403,7 +403,7 @@ cmDcmCfg_t* _cmDevCfgIndexToPtr( cmDcm_t* p, cmTypeDcmId_t typeId, unsigned inde
403 403
 
404 404
 const cmChar_t* cmDevCfgLabel( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned index )
405 405
 {
406
-  cmDcm_t*    p = _cmDcmHandleToPtr(h);
406
+  cmDcm_t*    p                                        = _cmDcmHandleToPtr(h);
407 407
   cmDcmCfg_t* cp;
408 408
   if((cp = _cmDevCfgIndexToPtr(p,typeId,index,false)) == NULL )
409 409
     return NULL;
@@ -428,7 +428,7 @@ cmDcmCfg_t* _cmDcmCfgLabelToPtr( cmDcm_t* p, cmTypeDcmId_t typeId, const cmChar_
428 428
   for(; cp!= NULL; cp=cp->next)
429 429
     if( cp->typeId == typeId )
430 430
     {
431
-      if( strcmp(cp->dcLabelStr,label)==0 )
431
+      if( strcmp(cp->dcLabelStr,label) == 0 )
432 432
         return cp;
433 433
     }
434 434
 
@@ -440,14 +440,14 @@ cmDcmCfg_t* _cmDcmCfgLabelToPtr( cmDcm_t* p, cmTypeDcmId_t typeId, const cmChar_
440 440
 
441 441
 unsigned cmDevCfgLabelToIndex( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* label )
442 442
 {
443
-  unsigned n = 0;
444
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
443
+  unsigned          n  = 0;
444
+  cmDcm_t*          p  = _cmDcmHandleToPtr(h);
445 445
   assert( p->clp != NULL);
446 446
   const cmDcmCfg_t* cp = p->clp->cfg;
447 447
   for(; cp!= NULL; cp=cp->next)
448 448
     if( cp->typeId == typeId )
449 449
     {
450
-      if( strcmp(cp->dcLabelStr,label)==0 )
450
+      if( strcmp(cp->dcLabelStr,label) == 0 )
451 451
         return n;
452 452
       ++n;
453 453
     }
@@ -479,14 +479,14 @@ cmDcmCfg_t*  _cmDcmFindOrCreateCfg( cmDcm_t* p, cmTypeDcmId_t typeId, const cmCh
479 479
   {
480 480
     if( cp->cfgId > newCfgId )
481 481
       newCfgId = cp->cfgId;
482
-    ep = cp;
482
+    ep         = cp;
483 483
   }
484 484
 
485 485
   // add one to the max cfgId to create a unique cfgId
486 486
   newCfgId += 1;
487 487
   
488 488
   // allocate a new cfg recd
489
-  cp = cmMemAllocZ(cmDcmCfg_t,1);
489
+  cp             = cmMemAllocZ(cmDcmCfg_t,1);
490 490
   cp->dcLabelStr = cmMemAllocStr(dcLabelStr);
491 491
   cp->cfgId      = newCfgId;
492 492
   cp->typeId     = typeId;
@@ -514,7 +514,7 @@ cmDcRC_t cmDevCfgDeleteCfg( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t*
514 514
 {
515 515
   cmDcmCfg_t* cp;
516 516
   cmDcm_t*    p = _cmDcmHandleToPtr(h);
517
-  unsigned i,j;
517
+  unsigned    i,j;
518 518
 
519 519
   // locate the cfg to delete
520 520
   if((cp = _cmDcmCfgLabelToPtr(p,typeId,dcLabelStr,true)) == NULL )
@@ -604,7 +604,7 @@ cmDcmMap_t* _cmDcmFindMap( cmDcm_t* p, cmTypeDcmId_t typeId, unsigned usrAppId,
604 604
 
605 605
 cmDcRC_t cmDevCfgDeleteMap( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned usrAppId, unsigned usrMapId )
606 606
 {
607
-  cmDcm_t*    p  = _cmDcmHandleToPtr(h);
607
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
608 608
   cmDcmMap_t* mp;
609 609
 
610 610
   if((mp = _cmDcmFindMap(p,typeId,usrAppId,usrMapId,false)) == NULL )
@@ -646,6 +646,7 @@ cmDcRC_t cmDevCfgNameMidiPort(
646 646
   if((cp = _cmDcmFindOrCreateCfg(p,kMidiDcmTId, dcLabelStr)) == NULL )
647 647
     return cmErrLastRC(&p->err);
648 648
 
649
+  cp->u.m.label        = cp->dcLabelStr;
649 650
   cp->u.m.devLabelStr  = cmMemResizeStr(cp->u.m.devLabelStr,devLabelStr);
650 651
   cp->u.m.portLabelStr = cmMemResizeStr(cp->u.m.portLabelStr,portLabelStr);
651 652
   cp->u.m.inputFl      = inputFl;
@@ -658,7 +659,7 @@ cmDcRC_t cmDevCfgNameMidiPort(
658 659
 
659 660
 const cmDcmMidi_t* cmDevCfgMidiCfg( cmDevCfgH_t h, unsigned cfgIdx )
660 661
 {
661
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
662
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
662 663
   cmDcmCfg_t* cp;
663 664
 
664 665
   if((cp = _cmDevCfgIndexToPtr(p, kMidiDcmTId, cfgIdx, true )) == NULL )
@@ -669,7 +670,7 @@ const cmDcmMidi_t* cmDevCfgMidiCfg( cmDevCfgH_t h, unsigned cfgIdx )
669 670
 
670 671
 const cmDcmMidi_t* cmDevCfgMidiDevMap( cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId )
671 672
 {
672
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
673
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
673 674
   cmDcmMap_t* mp;
674 675
 
675 676
   if((mp =_cmDcmFindMap(p,kMidiDcmTId, usrAppId, usrMapId, true )) == NULL )
@@ -713,10 +714,10 @@ cmDcRC_t cmDevCfgNameAudioPort(
713 714
   double          srate,
714 715
   bool            activeFl )
715 716
 {
716
-  cmDcm_t*    p = _cmDcmHandleToPtr(h);
717
+  cmDcm_t*    p         = _cmDcmHandleToPtr(h);
717 718
   cmDcmCfg_t* cp;
718
-  unsigned    inDevIdx   = cmInvalidIdx;
719
-  unsigned    outDevIdx  = cmInvalidIdx;
719
+  unsigned    inDevIdx  = cmInvalidIdx;
720
+  unsigned    outDevIdx = cmInvalidIdx;
720 721
 
721 722
   // validate the label
722 723
   if((dcLabelStr = _cmDcmTrimLabel(p,dcLabelStr,"Audio cfg")) == NULL)
@@ -756,19 +757,20 @@ cmDcRC_t cmDevCfgNameAudioPort(
756 757
   unsigned inChCnt  = cmApDeviceChannelCount( inDevIdx,  true );
757 758
   unsigned outChCnt = cmApDeviceChannelCount( outDevIdx, false );
758 759
 
759
-  cp->u.a.inDevLabelStr                  = cmMemAllocStr(inDevNameStr==NULL?"":inDevNameStr);
760
-  cp->u.a.outDevLabelStr                 = cmMemAllocStr(outDevNameStr==NULL?"":outDevNameStr);
761
-  cp->u.a.activeFl                       = activeFl;
762
-  cp->u.a.audioSysArgs.rpt               = p->err.rpt;
763
-  cp->u.a.audioSysArgs.inDevIdx          = inDevIdx;
764
-  cp->u.a.audioSysArgs.outDevIdx         = outDevIdx;
765
-  cp->u.a.audioSysArgs.syncInputFl       = syncInputFl;
766
-  cp->u.a.audioSysArgs.msgQueueByteCnt   = msgQueueByteCnt;
767
-  cp->u.a.audioSysArgs.devFramesPerCycle = devFramesPerCycle;
768
-  cp->u.a.audioSysArgs.dspFramesPerCycle = dspFramesPerCycle;
769
-  cp->u.a.audioSysArgs.audioBufCnt       = audioBufCnt;
770
-  cp->u.a.audioSysArgs.srate             = srate;
771
-  cp->descStr = cmTsPrintfP(cp->descStr,"%sIn: Chs:%i %s\nOut: Chs:%i %s",activeFl?"":"INACTIVE ",inChCnt,cp->u.a.inDevLabelStr,outChCnt,cp->u.a.outDevLabelStr);
760
+  cp->u.a.label                       = cp->dcLabelStr;
761
+  cp->u.a.inDevLabelStr               = cmMemAllocStr(inDevNameStr==NULL?"":inDevNameStr);
762
+  cp->u.a.outDevLabelStr              = cmMemAllocStr(outDevNameStr==NULL?"":outDevNameStr);
763
+  cp->u.a.activeFl                    = activeFl;
764
+  cp->u.a.rtSysArgs.rpt               = p->err.rpt;
765
+  cp->u.a.rtSysArgs.inDevIdx          = inDevIdx;
766
+  cp->u.a.rtSysArgs.outDevIdx         = outDevIdx;
767
+  cp->u.a.rtSysArgs.syncInputFl       = syncInputFl;
768
+  cp->u.a.rtSysArgs.msgQueueByteCnt   = msgQueueByteCnt;
769
+  cp->u.a.rtSysArgs.devFramesPerCycle = devFramesPerCycle;
770
+  cp->u.a.rtSysArgs.dspFramesPerCycle = dspFramesPerCycle;
771
+  cp->u.a.rtSysArgs.audioBufCnt       = audioBufCnt;
772
+  cp->u.a.rtSysArgs.srate             = srate;
773
+  cp->descStr                         = cmTsPrintfP(cp->descStr,"%sIn: Chs:%i %s\nOut: Chs:%i %s",activeFl?"":"INACTIVE ",inChCnt,cp->u.a.inDevLabelStr,outChCnt,cp->u.a.outDevLabelStr);
772 774
   return kOkDcRC;  
773 775
 }
774 776
 
@@ -776,7 +778,7 @@ cmDcRC_t cmDevCfgNameAudioPort(
776 778
 
777 779
 cmDcRC_t            cmDevCfgAudioSetDefaultCfgIndex( cmDevCfgH_t h, unsigned cfgIdx )
778 780
 {
779
-  cmDcm_t*    p  = _cmDcmHandleToPtr(h);
781
+  cmDcm_t* p = _cmDcmHandleToPtr(h);
780 782
 
781 783
   assert( p->clp != NULL );
782 784
 
@@ -803,7 +805,7 @@ cmDcRC_t            cmDevCfgAudioSetDefaultCfgIndex( cmDevCfgH_t h, unsigned cfg
803 805
 
804 806
 unsigned   cmDevCfgAudioGetDefaultCfgIndex( cmDevCfgH_t h )
805 807
 {
806
-  cmDcm_t*    p  = _cmDcmHandleToPtr(h);
808
+  cmDcm_t* p = _cmDcmHandleToPtr(h);
807 809
 
808 810
   assert( p->clp != NULL );
809 811
 
@@ -823,7 +825,7 @@ unsigned   cmDevCfgAudioGetDefaultCfgIndex( cmDevCfgH_t h )
823 825
 
824 826
 bool  cmDevCfgAudioIsDeviceActive( cmDevCfgH_t h, const cmChar_t* devNameStr, bool inputFl )
825 827
 {
826
-  cmDcm_t*    p  = _cmDcmHandleToPtr(h);
828
+  cmDcm_t* p = _cmDcmHandleToPtr(h);
827 829
 
828 830
   assert( p->clp != NULL );
829 831
 
@@ -851,7 +853,7 @@ bool  cmDevCfgAudioIsDeviceActive( cmDevCfgH_t h, const cmChar_t* devNameStr, bo
851 853
 
852 854
 unsigned            cmDevCfgAudioActiveCount( cmDevCfgH_t h )
853 855
 {
854
-  cmDcm_t*    p  = _cmDcmHandleToPtr(h);
856
+  cmDcm_t* p = _cmDcmHandleToPtr(h);
855 857
 
856 858
   assert( p->clp != NULL );
857 859
 
@@ -867,7 +869,7 @@ unsigned            cmDevCfgAudioActiveCount( cmDevCfgH_t h )
867 869
 
868 870
 const cmChar_t*     cmDevCfgAudioActiveLabel( cmDevCfgH_t h, unsigned idx )
869 871
 {
870
-  cmDcm_t*    p  = _cmDcmHandleToPtr(h);
872
+  cmDcm_t* p = _cmDcmHandleToPtr(h);
871 873
 
872 874
   assert( p->clp != NULL );
873 875
 
@@ -888,7 +890,7 @@ const cmChar_t*     cmDevCfgAudioActiveLabel( cmDevCfgH_t h, unsigned idx )
888 890
 
889 891
 const cmDcmAudio_t* cmDevCfgAudioActiveCfg(   cmDevCfgH_t h, unsigned idx )
890 892
 {
891
-  cmDcm_t*    p  = _cmDcmHandleToPtr(h);
893
+  cmDcm_t* p = _cmDcmHandleToPtr(h);
892 894
 
893 895
   assert( p->clp != NULL );
894 896
 
@@ -909,7 +911,7 @@ const cmDcmAudio_t* cmDevCfgAudioActiveCfg(   cmDevCfgH_t h, unsigned idx )
909 911
 
910 912
 unsigned  cmDevCfgAudioActiveIndex( cmDevCfgH_t h, const cmChar_t* cfgLabel )
911 913
 {
912
-  cmDcm_t*    p  = _cmDcmHandleToPtr(h);
914
+  cmDcm_t* p = _cmDcmHandleToPtr(h);
913 915
 
914 916
   if( cfgLabel == NULL )
915 917
     return cmInvalidIdx;
@@ -933,7 +935,7 @@ unsigned  cmDevCfgAudioActiveIndex( cmDevCfgH_t h, const cmChar_t* cfgLabel )
933 935
 
934 936
 const cmDcmAudio_t* cmDevCfgAudioCfg( cmDevCfgH_t h, unsigned cfgIdx )
935 937
 {
936
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
938
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
937 939
   cmDcmCfg_t* cp;
938 940
 
939 941
   if((cp = _cmDevCfgIndexToPtr(p, kAudioDcmTId, cfgIdx, true )) == NULL )
@@ -944,7 +946,7 @@ const cmDcmAudio_t* cmDevCfgAudioCfg( cmDevCfgH_t h, unsigned cfgIdx )
944 946
 
945 947
 const cmDcmAudio_t* cmDevCfgAudioDevMap(    cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId )
946 948
 {
947
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
949
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
948 950
   cmDcmMap_t* mp;
949 951
 
950 952
   if((mp =_cmDcmFindMap(p,kAudioDcmTId, usrAppId, usrMapId, true )) == NULL )
@@ -955,7 +957,7 @@ const cmDcmAudio_t* cmDevCfgAudioDevMap(    cmDevCfgH_t h, unsigned usrAppId, un
955 957
 
956 958
 
957 959
 cmDcRC_t cmDevCfgNameNetPort(
958
-  cmDevCfgH_t      h,
960
+  cmDevCfgH_t     h,
959 961
   const cmChar_t* dcLabelStr,
960 962
   const cmChar_t* sockAddr,
961 963
   unsigned        portNumber,
@@ -963,7 +965,7 @@ cmDcRC_t cmDevCfgNameNetPort(
963 965
   bool            activeFl)
964 966
 {
965 967
 
966
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
968
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
967 969
   cmDcmCfg_t* cp;
968 970
 
969 971
   if( portNumber > 0xffff )
@@ -978,11 +980,12 @@ cmDcRC_t cmDevCfgNameNetPort(
978 980
   if((cp = _cmDcmFindOrCreateCfg(p,kNetDcmTId, dcLabelStr)) == NULL )
979 981
     return cmErrLastRC(&p->err);
980 982
 
983
+  cp->u.n.label      = cp->dcLabelStr;
981 984
   cp->u.n.sockAddr   = cmMemAllocStr(sockAddr);
982 985
   cp->u.n.portNumber = portNumber;
983 986
   cp->u.n.localFl    = localFl;
984 987
   cp->u.n.activeFl   = activeFl;
985
-  cp->descStr = cmTsPrintfP(cp->descStr,"%s %s %s:%i",activeFl?"":"INACTIVE",localFl?"local":"remote",sockAddr,portNumber);
988
+  cp->descStr        = cmTsPrintfP(cp->descStr,"%s %s %s:%i",activeFl?"":"INACTIVE",localFl?"local":"remote",sockAddr,portNumber);
986 989
   
987 990
 
988 991
   return kOkDcRC;
@@ -1028,7 +1031,7 @@ const cmDcmNet_t* cmDevCfgNetActiveCfg( cmDevCfgH_t h, unsigned idx )
1028 1031
 
1029 1032
 const cmDcmNet_t* cmDevCfgNetCfg( cmDevCfgH_t h, unsigned cfgIdx )
1030 1033
 {
1031
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
1034
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
1032 1035
   cmDcmCfg_t* cp;
1033 1036
 
1034 1037
   if((cp = _cmDevCfgIndexToPtr(p, kNetDcmTId, cfgIdx, true )) == NULL )
@@ -1039,7 +1042,7 @@ const cmDcmNet_t* cmDevCfgNetCfg( cmDevCfgH_t h, unsigned cfgIdx )
1039 1042
 
1040 1043
 const cmDcmNet_t* cmDevCfgNetDevMap(    cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId )
1041 1044
 {
1042
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
1045
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
1043 1046
   cmDcmMap_t* mp;
1044 1047
 
1045 1048
   if((mp =_cmDcmFindMap(p,kNetDcmTId, usrAppId, usrMapId, true )) == NULL )
@@ -1050,8 +1053,8 @@ const cmDcmNet_t* cmDevCfgNetDevMap(    cmDevCfgH_t h, unsigned usrAppId, unsign
1050 1053
 
1051 1054
 unsigned        cmDevCfgLocCount(  cmDevCfgH_t h )
1052 1055
 {
1053
-  unsigned n = 0;
1054
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
1056
+  unsigned          n  = 0;
1057
+  cmDcm_t*          p  = _cmDcmHandleToPtr(h);
1055 1058
   const cmDcmLoc_t* lp = p->loc;
1056 1059
   for(; lp!=NULL; lp=lp->next)
1057 1060
     ++n;
@@ -1059,9 +1062,9 @@ unsigned        cmDevCfgLocCount(  cmDevCfgH_t h )
1059 1062
 }
1060 1063
 const cmChar_t* cmDevCfgLocLabel(  cmDevCfgH_t h, unsigned locIdx )
1061 1064
 {
1062
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
1065
+  cmDcm_t*          p  = _cmDcmHandleToPtr(h);
1063 1066
   const cmDcmLoc_t* lp = p->loc;
1064
-  unsigned i;
1067
+  unsigned          i;
1065 1068
   for(i=0; lp!=NULL; lp=lp->next,++i)
1066 1069
     if( i == locIdx )
1067 1070
       return lp->labelStr;
@@ -1076,7 +1079,7 @@ cmDcmLoc_t* _cmDcmLocLabelToPtr( cmDcm_t* p, const cmChar_t* locLabelStr, bool e
1076 1079
   if((locLabelStr = _cmDcmTrimLabel(p,locLabelStr,"location")) == NULL )
1077 1080
     return NULL;
1078 1081
 
1079
-  cmDcmLoc_t* lp = p->loc;
1082
+  cmDcmLoc_t* lp                          = p->loc;
1080 1083
   for(; lp!=NULL; lp=lp->next)
1081 1084
     if( strcmp(lp->labelStr,locLabelStr) == 0 )
1082 1085
       return lp;
@@ -1090,8 +1093,8 @@ cmDcmLoc_t* _cmDcmLocLabelToPtr( cmDcm_t* p, const cmChar_t* locLabelStr, bool e
1090 1093
 
1091 1094
 cmDcRC_t cmDevCfgLocStore(  cmDevCfgH_t h, const cmChar_t* locLabelStr )
1092 1095
 {
1093
-  cmDcRC_t  rc = kOkDcRC;
1094
-  cmDcm_t*   p = _cmDcmHandleToPtr(h);
1096
+  cmDcRC_t rc = kOkDcRC;
1097
+  cmDcm_t* p = _cmDcmHandleToPtr(h);
1095 1098
   unsigned i,j;
1096 1099
 
1097 1100
   // if this location label is already in use then it has already been stored.
@@ -1143,9 +1146,9 @@ cmDcRC_t cmDevCfgLocStore(  cmDevCfgH_t h, const cmChar_t* locLabelStr )
1143 1146
     cmDcmApp_t* oap = olp->app + i;
1144 1147
 
1145 1148
     //nap->usrAppId = oap->usrAppId;
1146
-    nap->activeFl = oap->activeFl;
1147
-    nap->mapCnt   = oap->mapCnt;
1148
-    nap->map      = cmMemAllocZ(cmDcmMap_t,nap->mapCnt);
1149
+    nap->activeFl   = oap->activeFl;
1150
+    nap->mapCnt     = oap->mapCnt;
1151
+    nap->map        = cmMemAllocZ(cmDcmMap_t,nap->mapCnt);
1149 1152
 
1150 1153
     for(j=0; j<nap->mapCnt; ++j)
1151 1154
     {
@@ -1156,7 +1159,7 @@ cmDcRC_t cmDevCfgLocStore(  cmDevCfgH_t h, const cmChar_t* locLabelStr )
1156 1159
       nmp->cfgId = omp->cfgId;
1157 1160
 
1158 1161
       if( omp->tid != kInvalidDcmTId && omp->cfg->dcLabelStr != NULL )
1159
-        nmp->cfg   = _cmDcmCfgLabelToPtr(p,nmp->tid,omp->cfg->dcLabelStr,true);
1162
+        nmp->cfg = _cmDcmCfgLabelToPtr(p,nmp->tid,omp->cfg->dcLabelStr,true);
1160 1163
     }
1161 1164
   }
1162 1165
   
@@ -1170,7 +1173,7 @@ cmDcRC_t cmDevCfgLocStore(  cmDevCfgH_t h, const cmChar_t* locLabelStr )
1170 1173
 
1171 1174
 cmDcRC_t cmDevCfgLocRecall( cmDevCfgH_t h, const cmChar_t* locLabelStr )
1172 1175
 {
1173
-  cmDcm_t*     p = _cmDcmHandleToPtr(h);
1176
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
1174 1177
   cmDcmLoc_t* lp;
1175 1178
 
1176 1179
   if((lp = _cmDcmLocLabelToPtr(p,locLabelStr,true)) == NULL)
@@ -1182,7 +1185,7 @@ cmDcRC_t cmDevCfgLocRecall( cmDevCfgH_t h, const cmChar_t* locLabelStr )
1182 1185
 }
1183 1186
 cmDcRC_t cmDevCfgLocDelete( cmDevCfgH_t h, const cmChar_t* locLabelStr )
1184 1187
 {
1185
-  cmDcm_t*     p = _cmDcmHandleToPtr(h);
1188
+  cmDcm_t*    p = _cmDcmHandleToPtr(h);
1186 1189
   cmDcmLoc_t* lp;
1187 1190
 
1188 1191
   if((lp = _cmDcmLocLabelToPtr(p,locLabelStr,true)) == NULL )
@@ -1195,8 +1198,8 @@ cmDcRC_t cmDevCfgLocDelete( cmDevCfgH_t h, const cmChar_t* locLabelStr )
1195 1198
 
1196 1199
 unsigned cmDevCfgLocCurIndex(  cmDevCfgH_t h )
1197 1200
 {
1198
-  unsigned i;
1199
-  cmDcm_t* p = _cmDcmHandleToPtr(h);
1201
+  unsigned    i;
1202
+  cmDcm_t*    p  = _cmDcmHandleToPtr(h);
1200 1203
   cmDcmLoc_t* lp = p->loc;
1201 1204
   for(i=0; lp!=NULL; lp=lp->next,++i)
1202 1205
     if( lp == p->clp )
@@ -1216,10 +1219,10 @@ cmDcRC_t _cmDevCfgRead( cmDcm_t* p, cmJsonH_t jsH, const cmJsonNode_t* rootObjPt
1216 1219
 {
1217 1220
   cmDcRC_t        rc          = kOkDcRC;
1218 1221
   const cmChar_t* errLabelPtr = NULL;
1219
-  cmJsonNode_t* cfgNp, *locArrNp;
1220
-  unsigned i,j;
1221
-  cmDevCfgH_t h;
1222
-  h.h = p;
1222
+  cmJsonNode_t*   cfgNp, *locArrNp;
1223
+  unsigned        i,j;
1224
+  cmDevCfgH_t     h;
1225
+  h.h                         = p;
1223 1226
 
1224 1227
   // clear the all locations
1225 1228
   _cmDcmFreeAllLocs(p);
@@ -1234,7 +1237,7 @@ cmDcRC_t _cmDevCfgRead( cmDcm_t* p, cmJsonH_t jsH, const cmJsonNode_t* rootObjPt
1234 1237
   // for each loc object
1235 1238
   for(i=0; i<cmJsonChildCount(locArrNp); ++i)
1236 1239
   {
1237
-    cmJsonNode_t* locObjNp, *cfgArrNp;
1240
+    cmJsonNode_t*   locObjNp, *cfgArrNp;
1238 1241
     const cmChar_t* locLabelStr = NULL;
1239 1242
 
1240 1243
     // get the loc object
@@ -1249,7 +1252,7 @@ cmDcRC_t _cmDevCfgRead( cmDcm_t* p, cmJsonH_t jsH, const cmJsonNode_t* rootObjPt
1249 1252
     { return _cmDcmJsonNotFound(p,errLabelPtr); }
1250 1253
 
1251 1254
     // create a new location recd
1252
-    cmDcmLoc_t* locPtr = NULL;
1255
+    cmDcmLoc_t* locPtr                             = NULL;
1253 1256
     if((rc = _cmDcmNewLoc(p,locLabelStr,&locPtr)) != kOkDcRC )
1254 1257
       return cmErrMsg(&p->err,kJsonFailDcRC,"Location '%s' create failed.",cmStringNullGuard(locLabelStr));
1255 1258
 
@@ -1274,7 +1277,7 @@ cmDcRC_t _cmDevCfgRead( cmDcm_t* p, cmJsonH_t jsH, const cmJsonNode_t* rootObjPt
1274 1277
         unsigned tid,cfgId;
1275 1278
         cmJsonNode_t* mapObjNp;
1276 1279
 
1277
-        if((mapObjNp = cmJsonArrayElement(mapArrNp,j))==NULL || cmJsonIsObject(mapObjNp)==false)
1280
+        if((mapObjNp = cmJsonArrayElement(mapArrNp,j)) == NULL || cmJsonIsObject(mapObjNp)==false)
1278 1281
           return _cmDcmJsonSyntaxErr(p,"cfg object");
1279 1282
 
1280 1283
         if( cmJsonMemberValues( mapObjNp, &errLabelPtr, 
@@ -1289,12 +1292,12 @@ cmDcRC_t _cmDevCfgRead( cmDcm_t* p, cmJsonH_t jsH, const cmJsonNode_t* rootObjPt
1289 1292
     // read each cfg object
1290 1293
     for(j=0; j<cmJsonChildCount(cfgArrNp); ++j)
1291 1294
     {
1292
-      cmJsonNode_t* cfgObjNp;
1295
+      cmJsonNode_t*   cfgObjNp;
1293 1296
       const cmChar_t* dcLabelStr;
1294 1297
       const cmChar_t* descStr;
1295
-      unsigned cfgId, typeId;
1298
+      unsigned        cfgId, typeId;
1296 1299
 
1297
-      if((cfgObjNp = cmJsonArrayElement(cfgArrNp,j))==NULL || cmJsonIsObject(cfgObjNp)==false)
1300
+      if((cfgObjNp = cmJsonArrayElement(cfgArrNp,j)) == NULL || cmJsonIsObject(cfgObjNp)==false)
1298 1301
         return _cmDcmJsonSyntaxErr(p,"cfg object");
1299 1302
       
1300 1303
       if( cmJsonMemberValues( cfgObjNp, &errLabelPtr,
@@ -1331,12 +1334,12 @@ cmDcRC_t _cmDevCfgRead( cmDcm_t* p, cmJsonH_t jsH, const cmJsonNode_t* rootObjPt
1331 1334
           if( cmJsonMemberValues( cfgObjNp, &errLabelPtr,
1332 1335
               "inDevLabelStr",     kStringTId, &a.inDevLabelStr,
1333 1336
               "outDevLabelStr",    kStringTId, &a.outDevLabelStr,
1334
-              "syncInputFl",       kBoolTId,   &a.audioSysArgs.syncInputFl,
1335
-              "msgQueueByteCnt",   kIntTId,    &a.audioSysArgs.msgQueueByteCnt,
1336
-              "devFramesPerCycle", kIntTId,    &a.audioSysArgs.devFramesPerCycle,
1337
-              "dspFramesPerCycle", kIntTId,    &a.audioSysArgs.dspFramesPerCycle,
1338
-              "audioBufCnt",       kIntTId,    &a.audioSysArgs.audioBufCnt,
1339
-              "srate",             kRealTId,   &a.audioSysArgs.srate,
1337
+              "syncInputFl",       kBoolTId,   &a.rtSysArgs.syncInputFl,
1338
+              "msgQueueByteCnt",   kIntTId,    &a.rtSysArgs.msgQueueByteCnt,
1339
+              "devFramesPerCycle", kIntTId,    &a.rtSysArgs.devFramesPerCycle,
1340
+              "dspFramesPerCycle", kIntTId,    &a.rtSysArgs.dspFramesPerCycle,
1341
+              "audioBufCnt",       kIntTId,    &a.rtSysArgs.audioBufCnt,
1342
+              "srate",             kRealTId,   &a.rtSysArgs.srate,
1340 1343
               "active",            kBoolTId,   &a.activeFl,
1341 1344
               NULL ) != kOkJsRC )
1342 1345
           {
@@ -1344,13 +1347,13 @@ cmDcRC_t _cmDevCfgRead( cmDcm_t* p, cmJsonH_t jsH, const cmJsonNode_t* rootObjPt
1344 1347
             goto errLabel;
1345 1348
           }
1346 1349
 
1347
-          if((rc = cmDevCfgNameAudioPort(h,dcLabelStr,a.inDevLabelStr,a.outDevLabelStr,
1348
-                a.audioSysArgs.syncInputFl,
1349
-                a.audioSysArgs.msgQueueByteCnt,
1350
-                a.audioSysArgs.devFramesPerCycle,
1351
-                a.audioSysArgs.dspFramesPerCycle,
1352
-                a.audioSysArgs.audioBufCnt,
1353
-                a.audioSysArgs.srate,
1350
+          if((rc              = cmDevCfgNameAudioPort(h,dcLabelStr,a.inDevLabelStr,a.outDevLabelStr,
1351
+                a.rtSysArgs.syncInputFl,
1352
+                a.rtSysArgs.msgQueueByteCnt,
1353
+                a.rtSysArgs.devFramesPerCycle,
1354
+                a.rtSysArgs.dspFramesPerCycle,
1355
+                a.rtSysArgs.audioBufCnt,
1356
+                a.rtSysArgs.srate,
1354 1357
                 a.activeFl)) != kOkDcRC )
1355 1358
           {
1356 1359
             goto errLabel;
@@ -1388,7 +1391,7 @@ cmDcRC_t _cmDevCfgRead( cmDcm_t* p, cmJsonH_t jsH, const cmJsonNode_t* rootObjPt
1388 1391
 
1389 1392
 cmDcRC_t _cmDevCfgWrite( cmDcm_t* p, cmJsonH_t jsH, cmJsonNode_t* rootObjPtr )
1390 1393
 {
1391
-  cmDcRC_t rc = kOkDcRC;
1394
+  cmDcRC_t          rc = kOkDcRC;
1392 1395
   const cmDcmLoc_t* lp = p->loc;
1393 1396
   
1394 1397
   cmJsonNode_t* cfgNp = cmJsonInsertPairObject(jsH, rootObjPtr, "cfg" );
@@ -1463,12 +1466,12 @@ cmDcRC_t _cmDevCfgWrite( cmDcm_t* p, cmJsonH_t jsH, cmJsonNode_t* rootObjPtr )
1463 1466
           cmJsonInsertPairs(jsH, cfgObjNp,
1464 1467
             "inDevLabelStr",     kStringTId, cp->u.a.inDevLabelStr,
1465 1468
             "outDevLabelStr",    kStringTId, cp->u.a.outDevLabelStr,
1466
-            "syncInputFl",       kBoolTId,   cp->u.a.audioSysArgs.syncInputFl,
1467
-            "msgQueueByteCnt",   kIntTId,    cp->u.a.audioSysArgs.msgQueueByteCnt,
1468
-            "devFramesPerCycle", kIntTId,    cp->u.a.audioSysArgs.devFramesPerCycle,
1469
-            "dspFramesPerCycle", kIntTId,    cp->u.a.audioSysArgs.dspFramesPerCycle,
1470
-            "audioBufCnt",       kIntTId,    cp->u.a.audioSysArgs.audioBufCnt,
1471
-            "srate",             kRealTId,   cp->u.a.audioSysArgs.srate,
1469
+            "syncInputFl",       kBoolTId,   cp->u.a.rtSysArgs.syncInputFl,
1470
+            "msgQueueByteCnt",   kIntTId,    cp->u.a.rtSysArgs.msgQueueByteCnt,
1471
+            "devFramesPerCycle", kIntTId,    cp->u.a.rtSysArgs.devFramesPerCycle,
1472
+            "dspFramesPerCycle", kIntTId,    cp->u.a.rtSysArgs.dspFramesPerCycle,
1473
+            "audioBufCnt",       kIntTId,    cp->u.a.rtSysArgs.audioBufCnt,
1474
+            "srate",             kRealTId,   cp->u.a.rtSysArgs.srate,
1472 1475
             "active",            kBoolTId,   cp->u.a.activeFl,
1473 1476
             NULL );
1474 1477
           break;

+ 8
- 5
cmDevCfg.h View File

@@ -67,6 +67,7 @@ extern "C" {
67 67
 
68 68
   typedef struct
69 69
   {
70
+    const cmChar_t* label;    // cfg label
70 71
     cmChar_t* devLabelStr;    // Midi device label.
71 72
     cmChar_t* portLabelStr;   // Midi device port label.
72 73
     bool      inputFl;        // 'True' if this is an input port.
@@ -76,19 +77,21 @@ extern "C" {
76 77
 
77 78
   typedef struct
78 79
   {
80
+    const cmChar_t* label;         // cfg label
79 81
     cmChar_t*     inDevLabelStr;  // Input audio device label.
80 82
     cmChar_t*     outDevLabelStr; // Output audio device label.
81
-    cmRtSysArgs_t audioSysArgs;   // Audio system  cfg recd
83
+    cmRtSysArgs_t rtSysArgs;      // RT system  cfg recd
82 84
     bool          dfltFl;         // true if this is the default audio cfg.
83 85
     bool          activeFl;
84 86
   } cmDcmAudio_t;
85 87
 
86 88
   typedef struct              
87 89
   {
88
-    cmChar_t* sockAddr;   // socket address.
89
-    unsigned  portNumber; // socket port number
90
-    bool      localFl;    // this is the local port
91
-    bool      activeFl;   // this port is active/inactive
90
+    const cmChar_t* label;      // cfg label
91
+    cmChar_t*       sockAddr;   // socket address.
92
+    unsigned        portNumber; // socket port number
93
+    bool            localFl;    // this is the local port
94
+    bool            activeFl;   // this port is active/inactive
92 95
   } cmDcmNet_t;
93 96
 
94 97
   extern cmDevCfgH_t cmDevCfgNullHandle;

Loading…
Cancel
Save