Browse Source

cmAudDsp.c : Added _cmAdSendProgramDefault(0 and _cmAdSendAudioSysCfgDefault().

master
kevin 8 years ago
parent
commit
555ac64cce
1 changed files with 64 additions and 10 deletions
  1. 64
    10
      cmAudDsp.c

+ 64
- 10
cmAudDsp.c View File

@@ -45,6 +45,7 @@ typedef struct
45 45
 typedef struct
46 46
 {
47 47
   const cmChar_t* label;
48
+  bool            dfltFl;
48 49
   cmAudioSysCfg_t cfg;
49 50
 } cmAdAsCfg_t;
50 51
 
@@ -88,6 +89,7 @@ typedef struct
88 89
   unsigned           midiPortBufByteCnt;
89 90
   unsigned           meterMs;
90 91
   unsigned           msgsPerClientPoll;
92
+  const cmChar_t*    dfltProgramLabel;
91 93
 
92 94
   cmAdAggDev_t*      aggDevArray;
93 95
   unsigned           aggDevCnt;
@@ -180,13 +182,14 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
180 182
 
181 183
   // locate the read the aud_dsp sub-elements
182 184
   if(( jsRC = cmJsonMemberValues( audDspNodePtr, &errLabelPtr, 
183
-        "midiPortBufByteCnt", kIntTId,   &p->midiPortBufByteCnt,
184
-        "meterMs",            kIntTId,   &p->meterMs,
185
-        "msgsPerClientPoll",  kIntTId,   &p->msgsPerClientPoll,
186
-        "audioSysCfgArray",   kArrayTId, &asCfgArrNodePtr,
187
-        "aggDevArray",        kArrayTId | kOptArgJsFl, &aggDevArrNodePtr,
188
-        "nrtDevArray",        kArrayTId | kOptArgJsFl, &nrtDevArrNodePtr,
189
-        "afpDevArray",        kArrayTId | kOptArgJsFl, &afpDevArrNodePtr,
185
+        "midiPortBufByteCnt", kIntTId,                  &p->midiPortBufByteCnt,
186
+        "meterMs",            kIntTId,                  &p->meterMs,
187
+        "msgsPerClientPoll",  kIntTId,                  &p->msgsPerClientPoll,
188
+        "dfltProgramLabel",   kStringTId | kOptArgJsFl, &p->dfltProgramLabel,
189
+        "audioSysCfgArray",   kArrayTId,                &asCfgArrNodePtr,
190
+        "aggDevArray",        kArrayTId  | kOptArgJsFl, &aggDevArrNodePtr,
191
+        "nrtDevArray",        kArrayTId  | kOptArgJsFl, &nrtDevArrNodePtr,
192
+        "afpDevArray",        kArrayTId  | kOptArgJsFl, &afpDevArrNodePtr,
190 193
         NULL )) != kOkJsRC )
191 194
   {
192 195
     rc = _cmAdParseMemberErr(p, jsRC, errLabelPtr, "aud_dsp" );
@@ -301,11 +304,13 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
301 304
     const cmJsonNode_t* asCfgNodePtr   = cmJsonArrayElementC(asCfgArrNodePtr,i);
302 305
     const cmJsonNode_t* ssArrayNodePtr = NULL;
303 306
     const char*         cfgLabel       = NULL;
304
-
307
+    bool                dfltFl         = false;
308
+    
305 309
     // read cmAsAudioSysCfg record values
306 310
     if(( jsRC = cmJsonMemberValues( asCfgNodePtr, &errLabelPtr, 
307
-        "label",   kStringTId, &cfgLabel,
308
-        "ssArray", kArrayTId, &ssArrayNodePtr,
311
+        "label",   kStringTId,             &cfgLabel,
312
+        "default", kTrueTId | kOptArgJsFl, &dfltFl,
313
+        "ssArray", kArrayTId,              &ssArrayNodePtr,
309 314
           NULL )) != kOkJsRC )
310 315
     {
311 316
       rc = _cmAdParseMemberErr(p, jsRC, errLabelPtr, cmStringNullGuard(p->asCfgArray[i].label) );
@@ -313,6 +318,7 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
313 318
     }
314 319
 
315 320
     p->asCfgArray[i].label            = cfgLabel;
321
+    p->asCfgArray[i].dfltFl           = dfltFl;
316 322
     p->asCfgArray[i].cfg.ssCnt        = cmJsonChildCount( ssArrayNodePtr );
317 323
     p->asCfgArray[i].cfg.ssArray      = cmMemResizeZ( cmAudioSysSubSys_t, p->asCfgArray[i].cfg.ssArray, p->asCfgArray[i].cfg.ssCnt );
318 324
     p->asCfgArray[i].cfg.clientCbFunc = _cmAudioSysToClientCallback;
@@ -452,6 +458,28 @@ cmAdRC_t _cmAdSendAudioSysCfgLabels( cmAd_t* p)
452 458
   return rc;  
453 459
 }
454 460
 
461
+cmAdRC_t _cmAdSendAudioSysCfgDefault( cmAd_t* p)
462
+{
463
+  cmAdRC_t     rc = kOkAdRC;
464
+  unsigned     i;
465
+
466
+  for(i=0; i<p->asCfgCnt; ++i)
467
+    if( p->asCfgArray[i].dfltFl )
468
+    {
469
+      cmDspValue_t v;
470
+      cmDsvSetStrcz(&v, p->asCfgArray[i].label);
471
+
472
+      if( cmMsgSend( &p->err,cmInvalidIdx,kUiSelAsId,kAudioSysCfgDfltDuiId,0,i,p->asCfgCnt,&v,p->cbFunc,p->cbDataPtr) != kOkMsgRC )
473
+        rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Error sending audio system default cfg. label message to host.");
474
+      
475
+      break;
476
+     
477
+    }
478
+   
479
+  return rc;  
480
+}
481
+
482
+
455 483
 cmAdRC_t _cmAdSendDeviceLabels( cmAd_t* p )
456 484
 {
457 485
   cmAdRC_t     rc = kOkAdRC;
@@ -503,6 +531,23 @@ cmAdRC_t _cmAdSendProgramLabels( cmAd_t* p )
503 531
   return rc;
504 532
 }
505 533
 
534
+cmAdRC_t _cmAdSendProgramDefault( cmAd_t* p)
535
+{
536
+  cmAdRC_t rc = kOkAdRC;
537
+  
538
+  if( p->dfltProgramLabel != NULL )
539
+  {
540
+    cmDspValue_t v;
541
+    cmDsvSetStrcz(&v, p->dfltProgramLabel);
542
+    
543
+    if( cmMsgSend( &p->err,cmInvalidIdx,kUiSelAsId,kProgramDfltDuiId,0,0,0,&v,p->cbFunc,p->cbDataPtr) != kOkMsgRC )
544
+      rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Error sending default program label message to host.");
545
+  }
546
+
547
+  return rc;
548
+}
549
+
550
+
506 551
 cmAdRC_t _cmAudDspFree( cmAd_t* p )
507 552
 {
508 553
   cmAdRC_t rc = kOkAdRC;
@@ -731,6 +776,15 @@ cmAdRC_t cmAudDspSendSetup( cmAdH_t h )
731 776
   // notify the client of the available programs
732 777
   if((rc = _cmAdSendProgramLabels(p)) != kOkAdRC )
733 778
     goto errLabel;
779
+
780
+  // notify the client of the default audio sys cfg
781
+  if((rc= _cmAdSendAudioSysCfgDefault(p)) != kOkAdRC )
782
+    goto errLabel;
783
+
784
+  // notify the client of the default program
785
+  if((rc= _cmAdSendProgramDefault(p)) != kOkAdRC )
786
+    goto errLabel;
787
+  
734 788
    
735 789
  errLabel:
736 790
   return rc;

Loading…
Cancel
Save