Skip to content

Commit eb2026e

Browse files
committed
.isRunning() issue - falling back to 'false' delayed #1020
1 parent 69abb69 commit eb2026e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Audio.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
audio.cpp
44
55
Created on: Oct 28.2018 */char audioI2SVers[] ="\
6-
Version 3.1.0v ";
6+
Version 3.1.0w ";
77
/* Updated on: Apr 28.2025
88
99
Author: Wolle (schreibfaul1)
@@ -3309,12 +3309,13 @@ void Audio::processWebFile() {
33093309
m_f_unknownFileLength = false; // no contentlength and no chunked data, maybe OpenAI-speech
33103310
}
33113311

3312+
m_f_clientIsConnected = _client->connected();
33123313
uint32_t availableBytes = _client->available(); // available from stream
33133314

33143315
// waiting for payload - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33153316
if(f_waitingForPayload){
33163317
if(availableBytes == 0){
3317-
if(m_t0 + 1000 > millis()) {
3318+
if(m_t0 + 3000 < millis()) {
33183319
f_waitingForPayload = false;
33193320
log_e("no payload received, timeout");
33203321
stopSong();
@@ -3350,8 +3351,9 @@ void Audio::processWebFile() {
33503351
}
33513352

33523353
// we have a webfile, read the file header first - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3354+
33533355
if(m_controlCounter != 100) {
3354-
if(InBuff.bufferFilled() > maxFrameSize || (InBuff.bufferFilled() == m_contentlength)) { // at least one complete frame or the file is smaller
3356+
if(InBuff.bufferFilled() > maxFrameSize || (m_contentlength && (InBuff.bufferFilled() == m_contentlength))) { // at least one complete frame or the file is smaller
33553357
int32_t bytesRead = readAudioHeader(InBuff.getMaxAvailableBytes());
33563358
if(bytesRead > 0) InBuff.bytesWasRead(bytesRead);
33573359
}
@@ -3668,11 +3670,12 @@ void Audio::playAudioData() {
36683670
uint8_t next = 0;
36693671
int bytesDecoded = 0;
36703672
if(f_isFile) {
3671-
bytesToDecode = m_audioDataSize - m_sumBytesDecoded;
3672-
if(bytesToDecode < InBuff.getMaxBlockSize()) {lastFrame = true;}
36733673
if(!m_f_unknownFileLength) {
3674+
bytesToDecode = m_audioDataSize - m_sumBytesDecoded;
3675+
if(bytesToDecode < InBuff.getMaxBlockSize()) {lastFrame = true;}
36743676
if(m_sumBytesDecoded >= m_audioDataSize && m_sumBytesDecoded != 0) {m_f_eof = true; goto exit;} // file end reached
36753677
}
3678+
else bytesToDecode = InBuff.bufferFilled();
36763679
}
36773680
if(!lastFrame) if(InBuff.bufferFilled() < InBuff.getMaxBlockSize()) goto exit;;
36783681

@@ -3700,7 +3703,7 @@ void Audio::playAudioData() {
37003703

37013704
exit:
37023705
if(m_f_unknownFileLength){
3703-
if(!_client->connected()){
3706+
if(m_f_clientIsConnected == false){
37043707
// log_w("InBuff.bufferFilled: %d, bytesDecoded %i", InBuff.bufferFilled(), bytesDecoded);
37053708
if(bytesDecoded == 0) {m_f_eof = true;} // file end reached
37063709
}

src/Audio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ char* x_ps_realloc(char* ptr, uint16_t len) {
726726
bool m_f_ID3v1TagFound = false; // ID3v1 tag found
727727
bool m_f_chunked = false ; // Station provides chunked transfer
728728
bool m_f_unknownFileLength = false; // file length unknown
729+
bool m_f_clientIsConnected = false; // client connected, inter task communication
729730
bool m_f_firstmetabyte = false; // True if first metabyte (counter)
730731
bool m_f_playing = false; // valid mp3 stream recognized
731732
bool m_f_tts = false; // text to speech

0 commit comments

Comments
 (0)