Snap for 7795143 from 299079a7d4a3b3768fc95ea4ecfad77d60b96b5b to sc-v2-release

Change-Id: I5e71bb925aeb3e2174300f8cd934e8b230da8bc8
diff --git a/arm-wt-22k/lib_src/eas_wtengine.c b/arm-wt-22k/lib_src/eas_wtengine.c
index 950616e..b1ee749 100644
--- a/arm-wt-22k/lib_src/eas_wtengine.c
+++ b/arm-wt-22k/lib_src/eas_wtengine.c
@@ -202,7 +202,7 @@
     loopEnd = (const EAS_SAMPLE*) pWTVoice->loopEnd + 1;
     pSamples = (const EAS_SAMPLE*) pWTVoice->phaseAccum;
     /*lint -e{713} truncation is OK */
-    phaseFrac = pWTVoice->phaseFrac;
+    phaseFrac = pWTVoice->phaseFrac & PHASE_FRAC_MASK;
     phaseInc = pWTIntFrame->frame.phaseIncrement;
 
     /* fetch adjacent samples */
@@ -218,6 +218,8 @@
 
     while (numSamples--) {
 
+        EAS_I32 nextSamplePhaseInc;
+
         /* linear interpolation */
         acc0 = samp2 - samp1;
         acc0 = acc0 * phaseFrac;
@@ -231,19 +233,19 @@
         /* increment phase */
         phaseFrac += phaseInc;
         /*lint -e{704} <avoid divide>*/
-        acc0 = phaseFrac >> NUM_PHASE_FRAC_BITS;
+        nextSamplePhaseInc = phaseFrac >> NUM_PHASE_FRAC_BITS;
 
         /* next sample */
-        if (acc0 > 0) {
-
+        if (nextSamplePhaseInc > 0) {
             /* advance sample pointer */
-            pSamples += acc0;
-            phaseFrac = (EAS_I32)((EAS_U32)phaseFrac & PHASE_FRAC_MASK);
+            pSamples +=  nextSamplePhaseInc;
+            phaseFrac = phaseFrac & PHASE_FRAC_MASK;
 
-            /* check for loop end */
-            acc0 = (EAS_I32) (pSamples - loopEnd);
-            if (acc0 >= 0)
-                pSamples = (const EAS_SAMPLE*) pWTVoice->loopStart + acc0;
+            /* decrementing pSamples by entire buffer length until second pSample is within */
+            /* loopEnd                                                                      */
+            while (&pSamples[1] >= loopEnd) {
+                pSamples -= (loopEnd - (const EAS_SAMPLE*)pWTVoice->loopStart);
+            }
 
             /* fetch new samples */
 #if defined(_8_BIT_SAMPLES)