|
3 | 3 | audio.cpp
|
4 | 4 |
|
5 | 5 | Created on: Oct 28.2018 */char audioI2SVers[] ="\
|
6 |
| - Version 3.1.0v "; |
| 6 | + Version 3.1.0w "; |
7 | 7 | /* Updated on: Apr 28.2025
|
8 | 8 |
|
9 | 9 | Author: Wolle (schreibfaul1)
|
@@ -3309,12 +3309,13 @@ void Audio::processWebFile() {
|
3309 | 3309 | m_f_unknownFileLength = false; // no contentlength and no chunked data, maybe OpenAI-speech
|
3310 | 3310 | }
|
3311 | 3311 |
|
| 3312 | + m_f_clientIsConnected = _client->connected(); |
3312 | 3313 | uint32_t availableBytes = _client->available(); // available from stream
|
3313 | 3314 |
|
3314 | 3315 | // waiting for payload - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
3315 | 3316 | if(f_waitingForPayload){
|
3316 | 3317 | if(availableBytes == 0){
|
3317 |
| - if(m_t0 + 1000 > millis()) { |
| 3318 | + if(m_t0 + 3000 < millis()) { |
3318 | 3319 | f_waitingForPayload = false;
|
3319 | 3320 | log_e("no payload received, timeout");
|
3320 | 3321 | stopSong();
|
@@ -3350,8 +3351,9 @@ void Audio::processWebFile() {
|
3350 | 3351 | }
|
3351 | 3352 |
|
3352 | 3353 | // we have a webfile, read the file header first - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 3354 | + |
3353 | 3355 | 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 |
3355 | 3357 | int32_t bytesRead = readAudioHeader(InBuff.getMaxAvailableBytes());
|
3356 | 3358 | if(bytesRead > 0) InBuff.bytesWasRead(bytesRead);
|
3357 | 3359 | }
|
@@ -3668,11 +3670,12 @@ void Audio::playAudioData() {
|
3668 | 3670 | uint8_t next = 0;
|
3669 | 3671 | int bytesDecoded = 0;
|
3670 | 3672 | if(f_isFile) {
|
3671 |
| - bytesToDecode = m_audioDataSize - m_sumBytesDecoded; |
3672 |
| - if(bytesToDecode < InBuff.getMaxBlockSize()) {lastFrame = true;} |
3673 | 3673 | if(!m_f_unknownFileLength) {
|
| 3674 | + bytesToDecode = m_audioDataSize - m_sumBytesDecoded; |
| 3675 | + if(bytesToDecode < InBuff.getMaxBlockSize()) {lastFrame = true;} |
3674 | 3676 | if(m_sumBytesDecoded >= m_audioDataSize && m_sumBytesDecoded != 0) {m_f_eof = true; goto exit;} // file end reached
|
3675 | 3677 | }
|
| 3678 | + else bytesToDecode = InBuff.bufferFilled(); |
3676 | 3679 | }
|
3677 | 3680 | if(!lastFrame) if(InBuff.bufferFilled() < InBuff.getMaxBlockSize()) goto exit;;
|
3678 | 3681 |
|
@@ -3700,7 +3703,7 @@ void Audio::playAudioData() {
|
3700 | 3703 |
|
3701 | 3704 | exit:
|
3702 | 3705 | if(m_f_unknownFileLength){
|
3703 |
| - if(!_client->connected()){ |
| 3706 | + if(m_f_clientIsConnected == false){ |
3704 | 3707 | // log_w("InBuff.bufferFilled: %d, bytesDecoded %i", InBuff.bufferFilled(), bytesDecoded);
|
3705 | 3708 | if(bytesDecoded == 0) {m_f_eof = true;} // file end reached
|
3706 | 3709 | }
|
|
0 commit comments