Only increment the ring index if data was successfully queued

This commit is contained in:
Cameron Gutman 2014-03-17 14:20:43 -04:00
parent 8c9d0d171c
commit eb15599c01

View File

@ -46,7 +46,6 @@ public class AudioDepacketizer {
else { else {
pcmData = pcmRing[ringIndex]; pcmData = pcmRing[ringIndex];
decodeLen = OpusDecoder.decode(data, off, len, pcmData); decodeLen = OpusDecoder.decode(data, off, len, pcmData);
ringIndex = (ringIndex + 1) % DU_LIMIT;
} }
if (decodeLen > 0) { if (decodeLen > 0) {
@ -61,6 +60,10 @@ public class AudioDepacketizer {
// Clear out the queue // Clear out the queue
decodedUnits.clear(); decodedUnits.clear();
} }
else {
// Frame successfully submitted for playback
ringIndex = (ringIndex + 1) % DU_LIMIT;
}
} }
} }