Fix the audio stutter during playback.
- Was using the base pointer from callback context when I meant to be
using the 'current position' pointer.
Bug: 5114126
Change-Id: Ie9baded973672cd8ac7ffe0f16f1bdf22c8f1030
diff --git a/variablespeed/jni/variablespeed.cc b/variablespeed/jni/variablespeed.cc
index 344eca5..e29846e 100644
--- a/variablespeed/jni/variablespeed.cc
+++ b/variablespeed/jni/variablespeed.cc
@@ -783,7 +783,7 @@
}
{
android::Mutex::Autolock autoLock(decodeBufferLock_);
- decodeBuffer_.AddData(pCntxt->pDataBase, kBufferSizeInBytes);
+ decodeBuffer_.AddData(pCntxt->pData, kBufferSizeInBytes);
}
if (!HasSampleRateAndChannels()) {
@@ -800,6 +800,8 @@
// ReadPosition(pCntxt->playItf);
}
+ OpenSL(queueItf, Enqueue, pCntxt->pData, kBufferSizeInBytes);
+
// Increase data pointer by buffer size
pCntxt->pData += kBufferSizeInBytes;
if (pCntxt->pData >= pCntxt->pDataBase +
@@ -807,8 +809,6 @@
pCntxt->pData = pCntxt->pDataBase;
}
- OpenSL(queueItf, Enqueue, pCntxt->pDataBase, kBufferSizeInBytes);
-
// If we get too much data into the decoder,
// sleep until the playback catches up.
while (!GetWasStopRequested() && DecodeBufferTooFull()) {