PASDK114: Bug in Circular buffer fixed for MAT streams (observed when metadata size...
[processor-sdk/performance-audio-sr.git] / pasdk / test_arm / framework / aspDecOpCircBuf_slave.c
index 97a85f7b94e4ac579f2fff60754d076d70d1d259..e0d2e14247fc0e38d97f59f55b54e7673858044f 100644 (file)
@@ -315,14 +315,18 @@ Int cbWriteAf(
 
 
         // prepare metadata buffer pointers according to the metadata and buffer sizes
-        for (i=1; i < pAfWrt->numPrivateMetadata; i++)
+        for (i=0; i < pAfWrt->numPrivateMetadata; i++)
         {
-            UInt8 *nextMdBuf = (pAfCb->pafPrivateMetadata[i-1].pMdBuf + pAfWrt->pafPrivateMetadata[i-1].size);
+            UInt8 *nextMdBuf;
+            if(i == 0)
+               nextMdBuf = (pAfCb->pafPrivateMetadata[0].pMdBuf + pAfWrt->pafPrivateMetadata[0].size);
+            else
+               nextMdBuf = (pAfCb->pafPrivateMetadata[i-1].pMdBuf + pAfWrt->pafPrivateMetadata[i-1].size);
             if(nextMdBuf >= pCb->metaBufEnd) // metadata buffer overflow
             {
                 pAfCb->pafPrivateMetadata[i].pMdBuf = pCb->metaBuf;
             }
-            else
+            else if(i != 0)
             {
                 pAfCb->pafPrivateMetadata[i].pMdBuf = nextMdBuf;
             }