Browse Source

cmAudioDsp.c,cmAudDspIF.h/c,cmMsgProtocol.h,cmDspClass.h:Changes to

new procedure cmDspSysPrintPgm().
master
kpl 11 years ago
parent
commit
c5b8c68e11
5 changed files with 61 additions and 15 deletions
  1. 36
    2
      cmAudDsp.c
  2. 19
    12
      cmAudDspIF.c
  3. 4
    0
      cmAudDspIF.h
  4. 1
    0
      cmMsgProtocol.h
  5. 1
    1
      dsp/cmDspClass.h

+ 36
- 2
cmAudDsp.c View File

943
 
943
 
944
   // the audio system must be configured before a program is loaded
944
   // the audio system must be configured before a program is loaded
945
   if((rc = _cmAdIsAudioSysLoaded(p)) != kOkAdRC )
945
   if((rc = _cmAdIsAudioSysLoaded(p)) != kOkAdRC )
946
-    return cmErrMsg(&p->err,rc,"Program load failed.");
946
+    return cmErrMsg(&p->err,rc,"The audio system is not configured. Program load failed.");
947
 
947
 
948
   // validate the sub-system index arg.
948
   // validate the sub-system index arg.
949
   if( asSubSysIdx!=cmInvalidIdx && asSubSysIdx >= p->dsSsCnt )
949
   if( asSubSysIdx!=cmInvalidIdx && asSubSysIdx >= p->dsSsCnt )
950
   {
950
   {
951
-    rc = cmErrMsg(&p->err,kInvalidSubSysIdxAdRC,"The sub-system index %i is invalid.",asSubSysIdx);
951
+    rc = cmErrMsg(&p->err,kInvalidSubSysIdxAdRC,"The sub-system index %i is invalid. Program load failed.",asSubSysIdx);
952
     goto errLabel;
952
     goto errLabel;
953
   }
953
   }
954
 
954
 
982
   return rc;
982
   return rc;
983
 }
983
 }
984
 
984
 
985
+cmAdRC_t _cmAudDspPrintPgm( cmAd_t* p, unsigned asSubSysIdx, const cmChar_t* fn )
986
+{
987
+  cmAdRC_t rc = kOkAdRC;
988
+  unsigned i;
989
+
990
+  // the audio system must be configured before a program is loaded
991
+  if((rc = _cmAdIsAudioSysLoaded(p)) != kOkAdRC )
992
+    return cmErrMsg(&p->err,rc,"The audio system is not configured. Program print failed.");
993
+
994
+  // validate the sub-system index arg.
995
+  if( asSubSysIdx!=cmInvalidIdx && asSubSysIdx >= p->dsSsCnt )
996
+  {
997
+    rc = cmErrMsg(&p->err,kInvalidSubSysIdxAdRC,"The sub-system index %i is invalid. Program print failed.",asSubSysIdx);
998
+    goto errLabel;
999
+  }
1000
+
1001
+  // for each sub-system
1002
+  for(i=0; i<p->dsSsCnt; ++i)
1003
+    if(  i==asSubSysIdx || asSubSysIdx==cmInvalidIdx )
1004
+    {
1005
+      if( cmDspSysPrintPgm(p->dsSsArray[i].dsH,fn) != kOkDspRC )
1006
+        rc = cmErrMsg(&p->err,kDspSysFailAdRC,"The program print failed.");
1007
+      
1008
+      break;
1009
+    }
1010
+
1011
+ errLabel:
1012
+  return rc;
1013
+}
1014
+
985
 cmAdRC_t _cmAdReinitAudioSys( cmAd_t* p )
1015
 cmAdRC_t _cmAdReinitAudioSys( cmAd_t* p )
986
 {
1016
 {
987
   cmAdRC_t rc = kOkAdRC;
1017
   cmAdRC_t rc = kOkAdRC;
1294
       rc = _cmAudDspClientMsgPoll(p);
1324
       rc = _cmAudDspClientMsgPoll(p);
1295
       break;
1325
       break;
1296
 
1326
 
1327
+    case kPrintPgmDuiId:
1328
+      _cmAudDspPrintPgm(p,m->asSubIdx,cmDsvStrcz(&m->value));
1329
+      break;
1330
+
1297
     default:
1331
     default:
1298
       if( cmAudioSysDeliverMsg(p->asH,msg,msgByteCnt,cmInvalidId) != kOkAsRC )
1332
       if( cmAudioSysDeliverMsg(p->asH,msg,msgByteCnt,cmInvalidId) != kOkAsRC )
1299
         rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Message delivery to the audio system failed.");
1333
         rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Message delivery to the audio system failed.");

+ 19
- 12
cmAudDspIF.c View File

148
 }
148
 }
149
 
149
 
150
 
150
 
151
-cmAiRC_t _cmAdIfSendIntMsg(cmAiH_t h, unsigned selId, unsigned asSubIdx, unsigned flags, unsigned iv, double dv )
151
+cmAiRC_t _cmAdIfSendIntMsg(cmAiH_t h, unsigned selId, unsigned asSubIdx, unsigned flags, unsigned iv, double dv, const cmChar_t* str )
152
 {  
152
 {  
153
   cmAi_t*      p = _cmAiHandleToPtr( h );
153
   cmAi_t*      p = _cmAiHandleToPtr( h );
154
   cmDspValue_t v;
154
   cmDspValue_t v;
155
 
155
 
156
-  if(iv == cmInvalidIdx )
157
-    cmDsvSetDouble(&v,dv);
156
+  if(str != NULL )
157
+    cmDsvSetStrcz(&v,str);
158
   else
158
   else
159
-    cmDsvSetUInt(&v,iv);
159
+    if(iv == cmInvalidIdx )
160
+      cmDsvSetDouble(&v,dv);
161
+    else
162
+      cmDsvSetUInt(&v,iv);
160
  
163
  
161
   if( cmMsgSend(&p->err,asSubIdx,kUiSelAsId,selId,flags,cmInvalidId,cmInvalidId,&v,p->parms.audDspFunc,p->parms.audDspFuncDataPtr) != kOkMsgRC )
164
   if( cmMsgSend(&p->err,asSubIdx,kUiSelAsId,selId,flags,cmInvalidId,cmInvalidId,&v,p->parms.audDspFunc,p->parms.audDspFuncDataPtr) != kOkMsgRC )
162
     return cmErrMsg(&p->err,kSendFailAiRC,"The integer message sel id:%i value:%i transmission failed.",selId,iv);
165
     return cmErrMsg(&p->err,kSendFailAiRC,"The integer message sel id:%i value:%i transmission failed.",selId,iv);
245
 }
248
 }
246
 
249
 
247
 cmAiRC_t        cmAdIfDeviceReport( cmAiH_t h )
250
 cmAiRC_t        cmAdIfDeviceReport( cmAiH_t h )
248
-{ return _cmAdIfSendIntMsg(h,kDevReportDuiId,cmInvalidIdx,0,cmInvalidIdx,0.0); }
251
+{ return _cmAdIfSendIntMsg(h,kDevReportDuiId,cmInvalidIdx,0,cmInvalidIdx,0.0,NULL); }
249
  
252
  
250
 cmAiRC_t        cmAdIfSetAudioSysCfg(   cmAiH_t h, unsigned asCfgIdx )
253
 cmAiRC_t        cmAdIfSetAudioSysCfg(   cmAiH_t h, unsigned asCfgIdx )
251
-{ return _cmAdIfSendIntMsg(h,kSetAudioCfgDuiId,cmInvalidIdx,0,asCfgIdx,0.0); }
254
+{ return _cmAdIfSendIntMsg(h,kSetAudioCfgDuiId,cmInvalidIdx,0,asCfgIdx,0.0,NULL); }
252
 
255
 
253
 cmAiRC_t        cmAdIfSetAudioDevice(   cmAiH_t h, unsigned asSubIdx, bool inputFl, unsigned devIdx )
256
 cmAiRC_t        cmAdIfSetAudioDevice(   cmAiH_t h, unsigned asSubIdx, bool inputFl, unsigned devIdx )
254
-{ return _cmAdIfSendIntMsg(h,kSetAudioDevDuiId,asSubIdx,inputFl,devIdx,0.0); }
257
+{ return _cmAdIfSendIntMsg(h,kSetAudioDevDuiId,asSubIdx,inputFl,devIdx,0.0,NULL); }
255
 
258
 
256
 cmAiRC_t        cmAdIfSetSampleRate(  cmAiH_t h, unsigned asSubIdx, double srate )
259
 cmAiRC_t        cmAdIfSetSampleRate(  cmAiH_t h, unsigned asSubIdx, double srate )
257
-{ return _cmAdIfSendIntMsg(h,kSetSampleRateDuiId,asSubIdx,0,cmInvalidIdx,srate); }
260
+{ return _cmAdIfSendIntMsg(h,kSetSampleRateDuiId,asSubIdx,0,cmInvalidIdx,srate,NULL); }
258
 
261
 
259
 cmAiRC_t        cmAdIfLoadProgram(   cmAiH_t h, unsigned asSubIdx, unsigned pgmIdx )
262
 cmAiRC_t        cmAdIfLoadProgram(   cmAiH_t h, unsigned asSubIdx, unsigned pgmIdx )
260
-{ return _cmAdIfSendIntMsg(h,kSetPgmDuiId,asSubIdx,0,pgmIdx,0.0); }
263
+{ return _cmAdIfSendIntMsg(h,kSetPgmDuiId,asSubIdx,0,pgmIdx,0.0,NULL); }
264
+
265
+cmAiRC_t        cmAdIfPrintPgm(   cmAiH_t h,unsigned asSubIdx, const cmChar_t* fn )
266
+{ return _cmAdIfSendIntMsg(h,kPrintPgmDuiId,asSubIdx,0,cmInvalidIdx,0.0,fn); }
267
+
261
   
268
   
262
 cmAiRC_t        cmAdIfEnableAudio( cmAiH_t h, bool enableFl )
269
 cmAiRC_t        cmAdIfEnableAudio( cmAiH_t h, bool enableFl )
263
-{ return _cmAdIfSendIntMsg(h,kEnableDuiId,cmInvalidIdx,enableFl,cmInvalidIdx,0.0); }
270
+{ return _cmAdIfSendIntMsg(h,kEnableDuiId,cmInvalidIdx,enableFl,cmInvalidIdx,0.0,NULL); }
264
 
271
 
265
 cmAiRC_t        cmAdIfEnableStatusNotify( cmAiH_t h, bool enableFl )
272
 cmAiRC_t        cmAdIfEnableStatusNotify( cmAiH_t h, bool enableFl )
266
-{ return _cmAdIfSendIntMsg(h,kSetNotifyEnableDuiId,cmInvalidIdx,enableFl,cmInvalidIdx,0.0); }
273
+{ return _cmAdIfSendIntMsg(h,kSetNotifyEnableDuiId,cmInvalidIdx,enableFl,cmInvalidIdx,0.0,NULL); }
267
 
274
 
268
 cmAiRC_t        cmAdIfSendMsgToAudioDSP( 
275
 cmAiRC_t        cmAdIfSendMsgToAudioDSP( 
269
   cmAiH_t             h, 
276
   cmAiH_t             h, 
287
 
294
 
288
 
295
 
289
 cmAiRC_t        cmAdIfDispatchMsgToHost(  cmAiH_t h ) 
296
 cmAiRC_t        cmAdIfDispatchMsgToHost(  cmAiH_t h ) 
290
-{ return _cmAdIfSendIntMsg(h,kClientMsgPollDuiId,cmInvalidIdx,0,cmInvalidIdx,0.0); }
297
+{ return _cmAdIfSendIntMsg(h,kClientMsgPollDuiId,cmInvalidIdx,0,cmInvalidIdx,0.0,NULL); }
291
 
298
 

+ 4
- 0
cmAudDspIF.h View File

118
   // prior to calling this function.
118
   // prior to calling this function.
119
   cmAiRC_t        cmAdIfLoadProgram(    cmAiH_t h, unsigned asSubIdx, unsigned pgmIdx );
119
   cmAiRC_t        cmAdIfLoadProgram(    cmAiH_t h, unsigned asSubIdx, unsigned pgmIdx );
120
 
120
 
121
+  // Print a representation (instances and connections) of the loaded program 
122
+  // to a JSON file.
123
+  cmAiRC_t        cmAdIfPrintPgm(   cmAiH_t h, unsigned asSubIdx, const cmChar_t* fn );
124
+
121
   // Start the audio streaming. 
125
   // Start the audio streaming. 
122
   // An audio configuration must have been selected via cmAdIfSetAudioSysCfg()
126
   // An audio configuration must have been selected via cmAdIfSetAudioSysCfg()
123
   // and a DSP program must have been selected via cmAdIfLoadProgram() 
127
   // and a DSP program must have been selected via cmAdIfLoadProgram() 

+ 1
- 0
cmMsgProtocol.h View File

47
     kClientMsgPollDuiId,   // Periodic check for and deliver messages waiting in the audio system for delivery to the client. 
47
     kClientMsgPollDuiId,   // Periodic check for and deliver messages waiting in the audio system for delivery to the client. 
48
     kSendMsgDuiId,         // forward msg to the audio system
48
     kSendMsgDuiId,         // forward msg to the audio system
49
     kDevReportDuiId,       // print a device report
49
     kDevReportDuiId,       // print a device report
50
+    kPrintPgmDuiId,        // write the currently loaded pgm as a JSON file
50
 
51
 
51
     kRightAlignDuiId = 0,  // label alignment id used by kLabelDuiId 
52
     kRightAlignDuiId = 0,  // label alignment id used by kLabelDuiId 
52
     kLeftAlignDuiId,  
53
     kLeftAlignDuiId,  

+ 1
- 1
dsp/cmDspClass.h View File

177
   typedef struct cmDspInst_str
177
   typedef struct cmDspInst_str
178
   {
178
   {
179
     struct cmDspClass_str* classPtr;  // ptr to class for this instance
179
     struct cmDspClass_str* classPtr;  // ptr to class for this instance
180
-    unsigned               symId;     // optional instance label symbol id
180
+    unsigned               symId;     // optional unique instance label symbol id
181
     unsigned               id;        // id is unique among all insts
181
     unsigned               id;        // id is unique among all insts
182
     unsigned               flags;     // See kXXXInstFl above
182
     unsigned               flags;     // See kXXXInstFl above
183
     cmDspVar_t*            varArray;  //
183
     cmDspVar_t*            varArray;  //

Loading…
Cancel
Save