@@ -339,7 +339,12 @@ bool ESP32_VS1053_Stream::connecttohost(const char *url, const char *username,
339
339
_metaDataStart = _http->header (ICY_METAINT).toInt ();
340
340
_musicDataPosition = _metaDataStart ? 0 : -100 ;
341
341
_bitrate = _http->header (BITRATE).toInt ();
342
- snprintf (_url, sizeof (_url), " %s" , url);
342
+ _url[0 ] = _savedStartChar;
343
+ if (strcmp (_url, url)) /* 0 means strings are equal*/
344
+ {
345
+ _vs1053->stopSong ();
346
+ snprintf (_url, sizeof (_url), " %s" , url);
347
+ }
343
348
_streamStalledTime = 0 ;
344
349
log_d (" redirected %i times" , _redirectCount);
345
350
_redirectCount = 0 ;
@@ -410,7 +415,7 @@ void ESP32_VS1053_Stream::_playFromRingBuffer()
410
415
return ;
411
416
}
412
417
const auto BAILOUT_MS = 2000 ;
413
- if (millis () - ringbufferEmpty > BAILOUT_MS)
418
+ if (millis () - ringbufferEmpty > BAILOUT_MS)
414
419
{
415
420
log_e (" Buffer empty for %i ms, bailing out..." , BAILOUT_MS);
416
421
_remainingBytes = 0 ;
@@ -572,7 +577,7 @@ void ESP32_VS1053_Stream::_handleChunkedStream(WiFiClient *const stream)
572
577
}
573
578
else
574
579
{
575
- const auto MAX_TIME_MS = 15 ;
580
+ const auto MAX_TIME_MS = 20 ;
576
581
const auto start = millis ();
577
582
// size_t bytesToDecoder = 0;
578
583
while (stream && stream->available () && _bytesLeftInChunk && _vs1053->data_request () && _musicDataPosition < _metaDataStart && millis () - start < MAX_TIME_MS)
@@ -693,7 +698,8 @@ void ESP32_VS1053_Stream::loop()
693
698
694
699
if (_startMute)
695
700
{
696
- const auto WAIT_TIME_MS = ((!_bitrate && _remainingBytes == -1 ) || _currentCodec == AAC || _currentCodec == AACP)
701
+ const auto WAIT_TIME_MS = ((!_bitrate && _remainingBytes == -1 ) ||
702
+ _currentCodec == AAC || _currentCodec == AACP || _currentCodec == OGG)
697
703
? 380
698
704
: 80 ;
699
705
if (millis () - _startMute > WAIT_TIME_MS)
@@ -738,13 +744,13 @@ void ESP32_VS1053_Stream::stopSong()
738
744
_http->end ();
739
745
delete _http;
740
746
_http = nullptr ;
741
- _vs1053->stopSong ();
742
747
_deallocateRingbuffer ();
743
748
_ringbuffer_filled = false ;
744
749
_dataSeen = false ;
745
750
_remainingBytes = 0 ;
746
751
_bytesLeftInChunk = 0 ;
747
752
_currentCodec = STOPPED;
753
+ _savedStartChar = _url[0 ];
748
754
_url[0 ] = 0 ;
749
755
_bitrate = 0 ;
750
756
_offset = 0 ;
@@ -796,6 +802,6 @@ const char *ESP32_VS1053_Stream::bufferStatus()
796
802
if (!_ringbuffer_handle)
797
803
return " 0/0" ;
798
804
static char ringbuffer_status[24 ];
799
- snprintf (ringbuffer_status, sizeof (ringbuffer_status), " %i/%i " , VS1053_PSRAM_BUFFER_SIZE - xRingbufferGetCurFreeSize (_ringbuffer_handle), VS1053_PSRAM_BUFFER_SIZE);
805
+ snprintf (ringbuffer_status, sizeof (ringbuffer_status), " %u/%lu " , VS1053_PSRAM_BUFFER_SIZE - xRingbufferGetCurFreeSize (_ringbuffer_handle), VS1053_PSRAM_BUFFER_SIZE);
800
806
return ringbuffer_status;
801
807
}
0 commit comments