Ver código fonte

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

new procedure cmDspSysPrintPgm().
master
kpl 11 anos atrás
pai
commit
c5b8c68e11
5 arquivos alterados com 61 adições e 15 exclusões
  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 Ver arquivo

@@ -943,12 +943,12 @@ cmAdRC_t _cmAudDspLoadPgm( cmAd_t* p, unsigned asSubSysIdx, unsigned pgmIdx )
943 943
 
944 944
   // the audio system must be configured before a program is loaded
945 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 948
   // validate the sub-system index arg.
949 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 952
     goto errLabel;
953 953
   }
954 954
 
@@ -982,6 +982,36 @@ cmAdRC_t _cmAudDspLoadPgm( cmAd_t* p, unsigned asSubSysIdx, unsigned pgmIdx )
982 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 1015
 cmAdRC_t _cmAdReinitAudioSys( cmAd_t* p )
986 1016
 {
987 1017
   cmAdRC_t rc = kOkAdRC;
@@ -1294,6 +1324,10 @@ cmAdRC_t cmAudDspReceiveClientMsg( cmAdH_t h, unsigned msgByteCnt, const void* m
1294 1324
       rc = _cmAudDspClientMsgPoll(p);
1295 1325
       break;
1296 1326
 
1327
+    case kPrintPgmDuiId:
1328
+      _cmAudDspPrintPgm(p,m->asSubIdx,cmDsvStrcz(&m->value));
1329
+      break;
1330
+
1297 1331
     default:
1298 1332
       if( cmAudioSysDeliverMsg(p->asH,msg,msgByteCnt,cmInvalidId) != kOkAsRC )
1299 1333
         rc = cmErrMsg(&p->err,kSendMsgFailAdRC,"Message delivery to the audio system failed.");

+ 19
- 12
cmAudDspIF.c Ver arquivo

@@ -148,15 +148,18 @@ cmAiRC_t _cmAdIfReadCfgFile( cmAi_t* p, cmCtx_t* ctx )
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 153
   cmAi_t*      p = _cmAiHandleToPtr( h );
154 154
   cmDspValue_t v;
155 155
 
156
-  if(iv == cmInvalidIdx )
157
-    cmDsvSetDouble(&v,dv);
156
+  if(str != NULL )
157
+    cmDsvSetStrcz(&v,str);
158 158
   else
159
-    cmDsvSetUInt(&v,iv);
159
+    if(iv == cmInvalidIdx )
160
+      cmDsvSetDouble(&v,dv);
161
+    else
162
+      cmDsvSetUInt(&v,iv);
160 163
  
161 164
   if( cmMsgSend(&p->err,asSubIdx,kUiSelAsId,selId,flags,cmInvalidId,cmInvalidId,&v,p->parms.audDspFunc,p->parms.audDspFuncDataPtr) != kOkMsgRC )
162 165
     return cmErrMsg(&p->err,kSendFailAiRC,"The integer message sel id:%i value:%i transmission failed.",selId,iv);
@@ -245,25 +248,29 @@ cmAiRC_t       cmAdIfRecvAudDspMsg( cmAiH_t h, unsigned msgByteCnt, const void*
245 248
 }
246 249
 
247 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 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 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 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 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 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 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 275
 cmAiRC_t        cmAdIfSendMsgToAudioDSP( 
269 276
   cmAiH_t             h, 
@@ -287,5 +294,5 @@ cmAiRC_t        cmAdIfSendMsgToAudioDSP(
287 294
 
288 295
 
289 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 Ver arquivo

@@ -118,6 +118,10 @@ extern "C" {
118 118
   // prior to calling this function.
119 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 125
   // Start the audio streaming. 
122 126
   // An audio configuration must have been selected via cmAdIfSetAudioSysCfg()
123 127
   // and a DSP program must have been selected via cmAdIfLoadProgram() 

+ 1
- 0
cmMsgProtocol.h Ver arquivo

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

+ 1
- 1
dsp/cmDspClass.h Ver arquivo

@@ -177,7 +177,7 @@ extern "C" {
177 177
   typedef struct cmDspInst_str
178 178
   {
179 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 181
     unsigned               id;        // id is unique among all insts
182 182
     unsigned               flags;     // See kXXXInstFl above
183 183
     cmDspVar_t*            varArray;  //

Carregando…
Cancelar
Salvar