Skip to content

Commit 928c420

Browse files
committed
Webfile, read audioheader first
schreibfaul1/ESP32-MiniWebRadio#471
1 parent 16818ec commit 928c420

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

src/Audio.cpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Created on: Oct 26.2018
55
*
6-
* Version 3.0.12d
6+
* Version 3.0.12e
77
* Updated on: Jul 29.2024
88
* Author: Wolle (schreibfaul1)
99
*
@@ -3273,16 +3273,6 @@ void Audio::processLocalFile() {
32733273
if(m_validSamples) {
32743274
return;
32753275
}
3276-
// int bytesDecoded = sendBytes(InBuff.getReadPtr(), InBuff.bufferFilled());
3277-
// if(bytesDecoded <= InBuff.bufferFilled()) { // avoid InBuff overrun (can be if file is corrupt)
3278-
// if(m_f_playing) {
3279-
// if(bytesDecoded > 2) {
3280-
// InBuff.bytesWasRead(bytesDecoded);
3281-
// return;
3282-
// }
3283-
// }
3284-
// }
3285-
// if(m_codec == CODEC_MP3) AUDIO_INFO("audio file is corrupt --> send EOF"); // no return, fall through
32863276
}
32873277
}
32883278

@@ -3417,6 +3407,7 @@ void Audio::processWebFile() {
34173407
byteCounter = 0;
34183408
chunkSize = 0;
34193409
audioDataCount = 0;
3410+
m_f_stream = false;
34203411
}
34213412

34223413
if(!m_contentlength && !m_f_tts) {
@@ -3453,11 +3444,11 @@ void Audio::processWebFile() {
34533444
InBuff.bytesWritten(bytesAddedToBuffer);
34543445
}
34553446

3456-
if(!m_f_stream) {
3447+
if(!m_f_stream && m_controlCounter == 100) {
34573448
if((InBuff.freeSpace() > maxFrameSize) && (byteCounter < m_contentlength)) return;
34583449
m_f_stream = true; // ready to play the audio data
34593450
uint16_t filltime = millis() - m_t0;
3460-
AUDIO_INFO("stream ready, buffer filled in %d ms", filltime);
3451+
AUDIO_INFO("Webfile: stream ready, buffer filled in %d ms", filltime);
34613452
return;
34623453
}
34633454

@@ -3498,11 +3489,11 @@ void Audio::processWebFile() {
34983489
if(m_validSamples) {
34993490
return;
35003491
} // play samples first
3501-
int bytesDecoded = sendBytes(InBuff.getReadPtr(), InBuff.bufferFilled());
3502-
if(bytesDecoded > 2) {
3503-
InBuff.bytesWasRead(bytesDecoded);
3504-
return;
3505-
}
3492+
// int bytesDecoded = sendBytes(InBuff.getReadPtr(), InBuff.bufferFilled());
3493+
// if(bytesDecoded > 2) {
3494+
// InBuff.bytesWasRead(bytesDecoded);
3495+
// return;
3496+
// }
35063497
}
35073498
}
35083499

src/Audio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Created on: Oct 28,2018
55
*
6-
* Version 3.0.12d
6+
* Version 3.0.12e
77
* Updated on: Jul 29.2024
88
* Author: Wolle (schreibfaul1)
99
*/

0 commit comments

Comments
 (0)