DLS: fix loop calculation for 16-bit am: 97f70ed81d am: 4f077e4de6

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/sonivox/+/18349826

Change-Id: I3856bb543c15d1ddbf184f3802e006762362a3d7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/arm-wt-22k/lib_src/eas_dlssynth.c b/arm-wt-22k/lib_src/eas_dlssynth.c
index 8606a29..a07262c 100644
--- a/arm-wt-22k/lib_src/eas_dlssynth.c
+++ b/arm-wt-22k/lib_src/eas_dlssynth.c
@@ -348,11 +348,24 @@
     pWTVoice->phaseAccum = (EAS_U32) pSynth->pDLS->pDLSSamples + pSynth->pDLS->pDLSSampleOffsets[pDLSRegion->wtRegion.waveIndex];
     if (pDLSRegion->wtRegion.region.keyGroupAndFlags & REGION_FLAG_IS_LOOPED)
     {
+#if defined (_8_BIT_SAMPLES)
         pWTVoice->loopStart = pWTVoice->phaseAccum + pDLSRegion->wtRegion.loopStart;
         pWTVoice->loopEnd = pWTVoice->phaseAccum + pDLSRegion->wtRegion.loopEnd - 1;
+#else //_16_BIT_SAMPLES
+        pWTVoice->loopStart = pWTVoice->phaseAccum + (pDLSRegion->wtRegion.loopStart<<1);
+        pWTVoice->loopEnd = pWTVoice->phaseAccum + (pDLSRegion->wtRegion.loopEnd<<1) - 2;
+#endif
     }
     else
-        pWTVoice->loopStart = pWTVoice->loopEnd = pWTVoice->phaseAccum + pSynth->pDLS->pDLSSampleLen[pDLSRegion->wtRegion.waveIndex] - 1;
+    {
+#if defined (_8_BIT_SAMPLES)
+       pWTVoice->loopStart = pWTVoice->loopEnd = pWTVoice->phaseAccum
+                + pSynth->pDLS->pDLSSampleLen[pDLSRegion->wtRegion.waveIndex] - 1;
+#else //_16_BIT_SAMPLES
+        pWTVoice->loopStart = pWTVoice->loopEnd = pWTVoice->phaseAccum
+                + pSynth->pDLS->pDLSSampleLen[pDLSRegion->wtRegion.waveIndex] - 2;
+#endif
+    }
 
     return EAS_SUCCESS;
 }