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
 typedef struct
45
 typedef struct
46
 {
46
 {
47
   const cmChar_t* label;
47
   const cmChar_t* label;
48
+  bool            dfltFl;
48
   cmAudioSysCfg_t cfg;
49
   cmAudioSysCfg_t cfg;
49
 } cmAdAsCfg_t;
50
 } cmAdAsCfg_t;
50
 
51
 
88
   unsigned           midiPortBufByteCnt;
89
   unsigned           midiPortBufByteCnt;
89
   unsigned           meterMs;
90
   unsigned           meterMs;
90
   unsigned           msgsPerClientPoll;
91
   unsigned           msgsPerClientPoll;
92
+  const cmChar_t*    dfltProgramLabel;
91
 
93
 
92
   cmAdAggDev_t*      aggDevArray;
94
   cmAdAggDev_t*      aggDevArray;
93
   unsigned           aggDevCnt;
95
   unsigned           aggDevCnt;
180
 
182
 
181
   // locate the read the aud_dsp sub-elements
183
   // locate the read the aud_dsp sub-elements
182
   if(( jsRC = cmJsonMemberValues( audDspNodePtr, &errLabelPtr, 
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
         NULL )) != kOkJsRC )
193
         NULL )) != kOkJsRC )
191
   {
194
   {
192
     rc = _cmAdParseMemberErr(p, jsRC, errLabelPtr, "aud_dsp" );
195
     rc = _cmAdParseMemberErr(p, jsRC, errLabelPtr, "aud_dsp" );
301
     const cmJsonNode_t* asCfgNodePtr   = cmJsonArrayElementC(asCfgArrNodePtr,i);
304
     const cmJsonNode_t* asCfgNodePtr   = cmJsonArrayElementC(asCfgArrNodePtr,i);
302
     const cmJsonNode_t* ssArrayNodePtr = NULL;
305
     const cmJsonNode_t* ssArrayNodePtr = NULL;
303
     const char*         cfgLabel       = NULL;
306
     const char*         cfgLabel       = NULL;
304
-
307
+    bool                dfltFl         = false;
308
+    
305
     // read cmAsAudioSysCfg record values
309
     // read cmAsAudioSysCfg record values
306
     if(( jsRC = cmJsonMemberValues( asCfgNodePtr, &errLabelPtr, 
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
           NULL )) != kOkJsRC )
314
           NULL )) != kOkJsRC )
310
     {
315
     {
311
       rc = _cmAdParseMemberErr(p, jsRC, errLabelPtr, cmStringNullGuard(p->asCfgArray[i].label) );
316
       rc = _cmAdParseMemberErr(p, jsRC, errLabelPtr, cmStringNullGuard(p->asCfgArray[i].label) );
313
     }
318
     }
314
 
319
 
315
     p->asCfgArray[i].label            = cfgLabel;
320
     p->asCfgArray[i].label            = cfgLabel;
321
+    p->asCfgArray[i].dfltFl           = dfltFl;
316
     p->asCfgArray[i].cfg.ssCnt        = cmJsonChildCount( ssArrayNodePtr );
322
     p->asCfgArray[i].cfg.ssCnt        = cmJsonChildCount( ssArrayNodePtr );
317
     p->asCfgArray[i].cfg.ssArray      = cmMemResizeZ( cmAudioSysSubSys_t, p->asCfgArray[i].cfg.ssArray, p->asCfgArray[i].cfg.ssCnt );
323
     p->asCfgArray[i].cfg.ssArray      = cmMemResizeZ( cmAudioSysSubSys_t, p->asCfgArray[i].cfg.ssArray, p->asCfgArray[i].cfg.ssCnt );
318
     p->asCfgArray[i].cfg.clientCbFunc = _cmAudioSysToClientCallback;
324
     p->asCfgArray[i].cfg.clientCbFunc = _cmAudioSysToClientCallback;
452
   return rc;  
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
 cmAdRC_t _cmAdSendDeviceLabels( cmAd_t* p )
483
 cmAdRC_t _cmAdSendDeviceLabels( cmAd_t* p )
456
 {
484
 {
457
   cmAdRC_t     rc = kOkAdRC;
485
   cmAdRC_t     rc = kOkAdRC;
503
   return rc;
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
 cmAdRC_t _cmAudDspFree( cmAd_t* p )
551
 cmAdRC_t _cmAudDspFree( cmAd_t* p )
507
 {
552
 {
508
   cmAdRC_t rc = kOkAdRC;
553
   cmAdRC_t rc = kOkAdRC;
731
   // notify the client of the available programs
776
   // notify the client of the available programs
732
   if((rc = _cmAdSendProgramLabels(p)) != kOkAdRC )
777
   if((rc = _cmAdSendProgramLabels(p)) != kOkAdRC )
733
     goto errLabel;
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
  errLabel:
789
  errLabel:
736
   return rc;
790
   return rc;

Loading…
Cancel
Save