Add Decoder Output Circular Buffer reset function
[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / pasdk / test_arm / framework / audioStreamDecodeProc.c
index 6a3fee8704cf67153e0167ea63f07e5c92a6c3bc..20db1fb76c982b06e1d7467e7e1d271852779ce0 100644 (file)
@@ -98,6 +98,10 @@ PAF_AudioData  *gDecAudioFrameChannelPointers[PAF_MAXNUMCHAN_AF];
 PAF_AudioSize  gDecAudioFrameChannelSizes[PAF_MAXNUMCHAN_AF];
 PAF_AudioData  *gDecOrigAudioFrameChannelPointers[PAF_MAXNUMCHAN_AF];
 
 PAF_AudioSize  gDecAudioFrameChannelSizes[PAF_MAXNUMCHAN_AF];
 PAF_AudioData  *gDecOrigAudioFrameChannelPointers[PAF_MAXNUMCHAN_AF];
 
+// Underflow threshold before returning error to Top-Level FSM
+#define DEC_OP_CB_WRTAF_OVR_THR  ( 20 ) // FL: arbitrary setting
+UInt32 gDecOpCbWrtAfOvr  =0; // decoder output circular buffer overflow count
+
 // Global debug counters */
 UInt32 gSlaveStartErrCnt        =0;
 UInt32 gSlaveStartCnt           =0;
 // Global debug counters */
 UInt32 gSlaveStartErrCnt        =0;
 UInt32 gSlaveStartCnt           =0;
@@ -639,7 +643,23 @@ Void taskAsdpFxn(
                         cbErrno = cbWriteAf(pCbCtl, z, pAfWrt);
                         if (cbErrno < 0)
                         {
                         cbErrno = cbWriteAf(pCbCtl, z, pAfWrt);
                         if (cbErrno < 0)
                         {
-                            SW_BREAKPOINT;
+                            //SW_BREAKPOINT; // FL: debug
+                            
+                            if (cbErrno == ASP_DECOP_CB_WRITE_OVERFLOW)
+                            {
+                                // Reset circular buffer
+                                cbReset(pCbCtl, z);
+                                // Update underflow count, return if above threshold
+                                gDecOpCbWrtAfOvr++;
+                                if (gDecOpCbWrtAfOvr < DEC_OP_CB_WRTAF_OVR_THR)
+                                {
+                                    cbErrno = 0;
+                                }
+                                else 
+                                {
+                                    gDecOpCbWrtAfOvr = 0;
+                                }
+                            }
                         }
                         TRACE_TERSE0("Dec:cbWriteAf() complete");
                         
                         }
                         TRACE_TERSE0("Dec:cbWriteAf() complete");