Skip to content

Commit cae706e

Browse files
committed
MP3 file ends prematurely if setFilePos() has been called. (Issue #999)
1 parent ae5f749 commit cae706e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Audio.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
audio.cpp
44
55
Created on: Oct 28.2018 */char audioI2SVers[] ="\
6-
Version 3.1.0s ";
7-
/* Updated on: Apr 22.2025
6+
Version 3.1.0t ";
7+
/* Updated on: Apr 23.2025
88
99
Author: Wolle (schreibfaul1)
1010
Audio library for ESP32 or ESP32-S3
@@ -3189,9 +3189,8 @@ void Audio::processLocalFile() {
31893189
while(m_f_audioTaskIsDecoding) vTaskDelay(1); // We can't reset the InBuffer while the decoding is in progress
31903190
audiofile.seek(m_resumeFilePos);
31913191
InBuff.resetBuffer();
3192-
m_sumBytesDecoded = m_haveNewFilePos = m_resumeFilePos;
3192+
m_haveNewFilePos = m_resumeFilePos;
31933193
m_resumeFilePos = -1;
3194-
if(m_codec == CODEC_MP3) MP3Decoder_ClearBuffer();
31953194
m_f_lockInBuffer = false;
31963195
}
31973196

@@ -4875,6 +4874,7 @@ bool Audio::setTimeOffset(int sec) { // fast forward or rewind the current posit
48754874

48764875
int32_t pos = getFilePos() - inBufferFilled();
48774876
pos += offset;
4877+
m_sumBytesDecoded += offset; // for the file length calculation
48784878
if(pos < (int32_t)startAB) {pos = startAB;}
48794879
if(pos >= (int32_t)endAB) {pos = endAB;}
48804880
setFilePos(pos);

0 commit comments

Comments
 (0)