Skip to content

Commit 56e9a42

Browse files
committed
bytesAddedToBuffer range extended
1 parent fd5d4f9 commit 56e9a42

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/Audio.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Created on: Oct 28.2018
55
*
6-
* Version 3.0.13y
6+
* Version 3.0.13z
77
* Updated on: Dec 15.2024
88
* Author: Wolle (schreibfaul1)
99
*
@@ -3240,6 +3240,8 @@ void Audio::processLocalFile() {
32403240
}
32413241
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
32423242
void Audio::processWebStream() {
3243+
if(m_dataMode != AUDIO_DATA) return; // guard
3244+
32433245
const uint16_t maxFrameSize = InBuff.getMaxBlockSize(); // every mp3/aac frame is not bigger
32443246
static uint32_t chunkSize; // chunkcount read from stream
32453247

@@ -3251,9 +3253,8 @@ void Audio::processWebStream() {
32513253
m_metacount = m_metaint;
32523254
readMetadata(0, true); // reset all static vars
32533255
}
3254-
3255-
if(m_dataMode != AUDIO_DATA) return; // guard
32563256
uint32_t availableBytes = _client->available(); // available from stream
3257+
32573258
// chunked data tramsfer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
32583259
if(m_f_chunked && availableBytes) {
32593260
uint8_t readedBytes = 0;
@@ -3277,28 +3278,25 @@ void Audio::processWebStream() {
32773278
// buffer fill routine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
32783279
if(availableBytes) {
32793280
availableBytes = min(availableBytes, (uint32_t)InBuff.writeSpace());
3280-
int16_t bytesAddedToBuffer = _client->read(InBuff.getWritePtr(), availableBytes);
3281-
3281+
int32_t bytesAddedToBuffer = _client->read(InBuff.getWritePtr(), availableBytes);
32823282
if(bytesAddedToBuffer > 0) {
3283+
32833284
if(m_f_metadata) m_metacount -= bytesAddedToBuffer;
32843285
if(m_f_chunked) chunkSize -= bytesAddedToBuffer;
32853286
InBuff.bytesWritten(bytesAddedToBuffer);
32863287
}
3288+
}
32873289

3288-
if(InBuff.bufferFilled() > maxFrameSize && !m_f_stream) { // waiting for buffer filled
3289-
if(m_codec == CODEC_OGG) { // log_i("determine correct codec here");
3290-
uint8_t codec = determineOggCodec(InBuff.getReadPtr(), maxFrameSize);
3291-
if(codec == CODEC_FLAC) {initializeDecoder(codec); m_codec = codec; return;}
3292-
if(codec == CODEC_OPUS) {initializeDecoder(codec); m_codec = codec; return;}
3293-
if(codec == CODEC_VORBIS) {initializeDecoder(codec); m_codec = codec; return;}
3294-
stopSong();
3295-
return;
3296-
}
3297-
AUDIO_INFO("stream ready");
3298-
m_f_stream = true; // ready to play the audio data
3290+
// start audio decoding - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3291+
if(InBuff.bufferFilled() > maxFrameSize && !m_f_stream) { // waiting for buffer filled
3292+
if(m_codec == CODEC_OGG) { // log_i("determine correct codec here");
3293+
uint8_t codec = determineOggCodec(InBuff.getReadPtr(), maxFrameSize);
3294+
if(codec == CODEC_FLAC) {initializeDecoder(codec); m_codec = codec;}
3295+
if(codec == CODEC_OPUS) {initializeDecoder(codec); m_codec = codec;}
3296+
if(codec == CODEC_VORBIS) {initializeDecoder(codec); m_codec = codec;}
32993297
}
3300-
if(!m_f_stream) return;
3301-
3298+
AUDIO_INFO("stream ready");
3299+
m_f_stream = true; // ready to play the audio data
33023300
}
33033301
}
33043302
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

src/Audio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* Created on: Oct 28,2018
66
*
7-
* Version 3.0.13x
8-
* Updated on: Dec 01.2024
7+
* Version 3.0.13z
8+
* Updated on: Dec 16.2024
99
* Author: Wolle (schreibfaul1)
1010
*/
1111

0 commit comments

Comments
 (0)