Fix buffering losing bytes

Correct issue @armSeb found and fixed where some bytes on the fallthrough
case were not being recorded as stored, leading to mp3 playback errors.
Fixes one half of issue 7.
This commit is contained in:
Earle F. Philhower, III committed 2017-11-20 06:59:57 -08:00
1 parent 3f7cf95a15
commit 8a19c9c093
1 file changed
+2 -4
+2 -4
View File
@@ -94,9 +94,9 @@ uint32_t AudioFileSourceBuffer::read(void *data, uint32_t len)
readPtr = (readPtr + toReadToEnd) % buffSize;
len -= toReadToEnd;
length -= toReadToEnd;
toReadFromBuffer -= toReadToEnd;
ptr += toReadToEnd;
bytes += toReadToEnd;
toReadFromBuffer -= toReadToEnd;
}
if (toReadFromBuffer > 0) { // We know RP < WP at this point
// Serial.printf("readhead: toReadFromBuffer=%d, rp=%d, wp=%d\n", toReadFromBuffer, readPtr, writePtr);
@@ -104,9 +104,9 @@ uint32_t AudioFileSourceBuffer::read(void *data, uint32_t len)
readPtr = (readPtr + toReadFromBuffer) % buffSize;
len -= toReadFromBuffer;
length -= toReadFromBuffer;
toReadFromBuffer -= toReadFromBuffer;
ptr += toReadFromBuffer;
bytes += toReadFromBuffer;
toReadFromBuffer -= toReadFromBuffer;
}
// Serial.printf("read %d from buffer, %d avail in buff, %d remaining for request\n", bytes, length, len);
@@ -129,8 +129,6 @@ uint32_t AudioFileSourceBuffer::read(void *data, uint32_t len)
return bytes;
}
int bytesAvailEnd = buffSize - writePtr;
if (bytesAvailEnd > 0) {
//Serial.print("at end: ");