Bladeren bron

cmAudDsp.h/c, cmAudioNrtDev.c,cmAudioSys.h : Audio devices are now set in aud_dsp.js by their name rather than their index.

master
kevin 4 jaren geleden
bovenliggende
commit
186f815636
4 gewijzigde bestanden met toevoegingen van 62 en 14 verwijderingen
  1. 44
    3
      src/cmAudDsp.c
  2. 2
    1
      src/cmAudDsp.h
  3. 4
    0
      src/cmAudioNrtDev.c
  4. 12
    10
      src/cmAudioSys.h

+ 44
- 3
src/cmAudDsp.c Bestand weergeven

@@ -354,10 +354,15 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
354 354
     {
355 355
       cmAudioSysArgs_t*   asap        = &p->asCfgArray[i].cfg.ssArray[j].args;
356 356
       const cmJsonNode_t* argsNodePtr = cmJsonArrayElementC(ssArrayNodePtr,j);
357
+      
358
+      asap->inDevIdx    = cmInvalidIdx;
359
+      asap->outDevIdx   = cmInvalidIdx;
360
+      asap->inDevLabel  = NULL;
361
+      asap->outDevLabel = NULL;
357 362
 
358 363
       if((jsRC = cmJsonMemberValues( argsNodePtr, &errLabelPtr,
359
-          "inDevIdx",           kIntTId,  &asap->inDevIdx,
360
-          "outDevIdx",          kIntTId,  &asap->outDevIdx,
364
+          "inDevLabel",         kStringTId,  &asap->inDevLabel,
365
+          "outDevLabel",        kStringTId,  &asap->outDevLabel,
361 366
           "syncToInputFl",      kTrueTId, &asap->syncInputFl,
362 367
           "msgQueueByteCnt",    kIntTId,  &asap->msgQueueByteCnt,
363 368
           "devFramesPerCycle",  kIntTId,  &asap->devFramesPerCycle,
@@ -443,6 +448,35 @@ cmAdRC_t _cmAdCreateAggDevices( cmAd_t* p )
443 448
   return rc;
444 449
 }
445 450
 
451
+cmAdRC_t _cmAdResolveDeviceLabels( cmAd_t* p )
452
+{
453
+  cmAdRC_t rc = kOkAdRC;
454
+  unsigned i,j;
455
+  
456
+  // for each cmAsAudioSysCfg record in audioSysCfgArray[]
457
+  for(i=0; i<p->asCfgCnt; ++i)
458
+  {
459
+    // for each audio system sub-subsystem 
460
+    for(j=0; j<p->asCfgArray[i].cfg.ssCnt; ++j)
461
+    {
462
+      cmAudioSysArgs_t*   asap        = &p->asCfgArray[i].cfg.ssArray[j].args;
463
+      if((asap->inDevIdx = cmApDeviceLabelToIndex( asap->inDevLabel )) == cmInvalidId )
464
+      {
465
+        rc = cmErrMsg(&p->err,kInvalidAudioDevIdxAdRC,"The audio input device '%s' could not be found.", cmStringNullGuard(asap->inDevLabel));
466
+        goto errLabel;
467
+      }
468
+      
469
+      if((asap->outDevIdx = cmApDeviceLabelToIndex( asap->outDevLabel )) == cmInvalidId )
470
+      {
471
+        rc = cmErrMsg(&p->err,kInvalidAudioDevIdxAdRC,"The audio input device '%s' could not be found.", cmStringNullGuard(asap->inDevLabel));
472
+        goto errLabel;
473
+      }
474
+    }
475
+  }
476
+ errLabel:
477
+  return rc;
478
+}
479
+
446 480
 cmAdRC_t _cmAdCreateNrtDevices( cmAd_t* p )
447 481
 {
448 482
   cmAdRC_t rc = kOkAdRC;
@@ -721,10 +755,11 @@ cmAdRC_t cmAudDspAlloc( cmCtx_t* ctx, cmAdH_t* hp, cmMsgSendFuncPtr_t cbFunc, vo
721 755
   if((rc = _cmAdParseSysJsonTree(p)) != kOkAdRC )
722 756
     goto errLabel;
723 757
 
758
+ 
724 759
   // create the aggregate device
725 760
   if( _cmAdCreateAggDevices(p) != kOkAdRC )
726 761
     goto errLabel;
727
-
762
+  
728 763
   // create the non-real-time devices
729 764
   if( _cmAdCreateNrtDevices(p) != kOkAdRC )
730 765
     goto errLabel;
@@ -740,6 +775,12 @@ cmAdRC_t cmAudDspAlloc( cmCtx_t* ctx, cmAdH_t* hp, cmMsgSendFuncPtr_t cbFunc, vo
740 775
     goto errLabel;
741 776
   }
742 777
 
778
+  if( _cmAdResolveDeviceLabels(p) != kOkApRC )
779
+  {
780
+    rc = cmErrMsg(&p->err,kAudioPortFailAdRC,"Audio device labels could not be resolved..");
781
+    goto errLabel;
782
+  }
783
+
743 784
   // initialize the audio buffer
744 785
   if( cmApBufInitialize( cmApDeviceCount(), p->meterMs ) != kOkApRC )
745 786
   {

+ 2
- 1
src/cmAudDsp.h Bestand weergeven

@@ -27,7 +27,8 @@ extern "C" {
27 27
     kAggDevCreateFailAdRC,
28 28
     kNrtDevSysFailAdRC,
29 29
     kAfpDevSysFailAdRC,
30
-    kNetSysFailAdRC
30
+    kNetSysFailAdRC,
31
+    kInvalidAudioDevIdxAdRC
31 32
   };
32 33
 
33 34
 

+ 4
- 0
src/cmAudioNrtDev.c Bestand weergeven

@@ -189,6 +189,10 @@ cmApRC_t cmApNrtAllocate( cmRpt_t* rpt )
189 189
 cmApRC_t cmApNrtFree()
190 190
 {
191 191
   cmApRC_t rc = kOkApRC;
192
+  
193
+  if( _cmNrt == NULL )
194
+    return rc;
195
+  
192 196
   cmApNrtDev_t* dp = _cmNrt->devs;
193 197
   while( dp != NULL )
194 198
   {

+ 12
- 10
src/cmAudioSys.h Bestand weergeven

@@ -130,16 +130,18 @@ extern "C" {
130 130
   // Audio device sub-sytem configuration record 
131 131
   typedef struct cmAudioSysArgs_str
132 132
   {
133
-    cmRpt_t*       rpt;               // system console object
134
-    unsigned       inDevIdx;          // input audio device
135
-    unsigned       outDevIdx;         // output audio device
136
-    bool           syncInputFl;       // true/false sync the DSP update callbacks with audio input/output
137
-    unsigned       msgQueueByteCnt;   // Size of the internal msg queue used to buffer msgs arriving via cmAudioSysDeliverMsg().
138
-    unsigned       devFramesPerCycle; // (512) Audio device samples per channel per device update buffer.
139
-    unsigned       dspFramesPerCycle; // (64)  Audio samples per channel per DSP cycle.
140
-    unsigned       audioBufCnt;       // (3)   Audio device buffers.
141
-    double         srate;             // Audio sample rate.
142
-    int            srateMult;         // Sample rate multiplication factor (negative for divide)
133
+    cmRpt_t*        rpt;               // system console object
134
+    const cmChar_t* inDevLabel;        // input audio device text label
135
+    const cmChar_t* outDevLabel;       // output audio device text label
136
+    unsigned        inDevIdx;          // input audio device index
137
+    unsigned        outDevIdx;         // output audio device index 
138
+    bool            syncInputFl;       // true/false sync the DSP update callbacks with audio input/output
139
+    unsigned        msgQueueByteCnt;   // Size of the internal msg queue used to buffer msgs arriving via cmAudioSysDeliverMsg().
140
+    unsigned        devFramesPerCycle; // (512) Audio device samples per channel per device update buffer.
141
+    unsigned        dspFramesPerCycle; // (64)  Audio samples per channel per DSP cycle.
142
+    unsigned        audioBufCnt;       // (3)   Audio device buffers.
143
+    double          srate;             // Audio sample rate.
144
+    int             srateMult;         // Sample rate multiplication factor (negative for divide)
143 145
   } cmAudioSysArgs_t;
144 146
 
145 147
   // Audio sub-system configuration record.

Laden…
Annuleren
Opslaan