Browse Source

cmRtSys.c:_cmRtDspExecCallback() now contains network update and message send.

This is a cleaner representation than the original code.
master
kevin 11 years ago
parent
commit
c0259b6777
1 changed files with 34 additions and 31 deletions
  1. 34
    31
      cmRtSys.c

+ 34
- 31
cmRtSys.c View File

@@ -244,6 +244,22 @@ cmRtRC_t _cmRtSendStateStatusToHost(  _cmRtCfg_t* cp )
244 244
   return rc;
245 245
 }
246 246
 
247
+// This is only called with _cmRtRecd.engMutexH locked
248
+cmRtRC_t _cmRtDeliverMsgsWithLock( _cmRtCfg_t* cp  )
249
+{
250
+  int      i;
251
+  cmRtRC_t rc = kOkThRC;
252
+    
253
+  // as long as their may be a msg wating in the incoming msg queue
254
+  for(i=0; rc == kOkThRC; ++i)
255
+  {
256
+    // if a msg is waiting transmit it via cfg->cbFunc()
257
+    if((rc = cmTsMp1cDequeueMsg(cp->htdQueueH,NULL,0)) == kOkThRC)
258
+      ++cp->status.msgCbCnt;
259
+  }
260
+
261
+  return rc;
262
+}
247 263
 
248 264
 // The DSP execution callback happens through this function.
249 265
 // This function is only called from inside _cmRtThreadCallback() 
@@ -258,6 +274,20 @@ void _cmRtDspExecCallback( _cmRtCfg_t* cp )
258 274
   //   3) All samples returned in oChArray[] buffers will be set to zero.
259 275
   cmApBufGetIO(cp->ss.args.inDevIdx, cp->ctx.iChArray, cp->ctx.iChCnt, cp->ss.args.outDevIdx, cp->ctx.oChArray, cp->ctx.oChCnt  );
260 276
 
277
+
278
+  // calling this function results in callbacks to _gtNetRecv()
279
+  // which in turn calls cmRtSysDeliverMsg() which queues any incoming messages
280
+  // which are then transferred to the DSP processes by the the call to 
281
+  // _cmRtDeliverMsgWithLock() below.
282
+  if( cp->cbEnableFl )
283
+    cmUdpGetAvailData(cp->udpH,NULL,NULL,NULL);
284
+    
285
+  // if there are msgs waiting to be sent to the DSP process send them. 
286
+  if( cp->cbEnableFl )
287
+    if( cmTsMp1cMsgWaiting(cp->htdQueueH) )
288
+      _cmRtDeliverMsgsWithLock(cp); 
289
+
290
+
261 291
   // call the application provided DSP process
262 292
   if( cp->cbEnableFl )
263 293
   {
@@ -318,22 +348,6 @@ bool _cmRtBufIsReady( const _cmRtCfg_t* cp )
318 348
 }
319 349
 
320 350
 
321
-// This is only called with _cmRtRecd.engMutexH locked
322
-cmRtRC_t _cmRtDeliverMsgsWithLock( _cmRtCfg_t* cp  )
323
-{
324
-  int      i;
325
-  cmRtRC_t rc = kOkThRC;
326
-    
327
-  // as long as their may be a msg wating in the incoming msg queue
328
-  for(i=0; rc == kOkThRC; ++i)
329
-  {
330
-    // if a msg is waiting transmit it via cfg->cbFunc()
331
-    if((rc = cmTsMp1cDequeueMsg(cp->htdQueueH,NULL,0)) == kOkThRC)
332
-      ++cp->status.msgCbCnt;
333
-  }
334
-
335
-  return rc;
336
-}
337 351
 
338 352
 
339 353
 // This is the main audio system loop (and thread callback function).
@@ -381,23 +395,12 @@ bool _cmRtThreadCallback(void* arg)
381 395
     {
382 396
       ++cp->status.audioCbCnt;
383 397
         
384
-      // calling this function results in callbacks to _gtNetRecv()
385
-      // which in turn calls cmRtSysDeliverMsg() which queues any incoming messages
386
-      // which are then transferred to the DSP processes by the the call to 
387
-        // _cmRtDeliverMsgWithLock() below.
388
-      if( cp->cbEnableFl )
389
-        cmUdpGetAvailData(cp->udpH,NULL,NULL,NULL);
390
-    
391
-      // if there are msgs waiting to be sent to the DSP process send them. 
392
-        if( cp->cbEnableFl )
393
-          if( cmTsMp1cMsgWaiting(cp->htdQueueH) )
394
-            _cmRtDeliverMsgsWithLock(cp); 
395 398
 
396
-        // make the cmRtSys callback
397
-        _cmRtDspExecCallback( cp ); 
399
+      // make the cmRtSys callback
400
+      _cmRtDspExecCallback( cp ); 
398 401
         
399
-        // update the signal time
400
-        cp->ctx.begSmpIdx += cp->ss.args.dspFramesPerCycle;
402
+      // update the signal time
403
+      cp->ctx.begSmpIdx += cp->ss.args.dspFramesPerCycle;
401 404
     }
402 405
    
403 406
   } 

Loading…
Cancel
Save