copyErrors: be more robust against occasional copier.copy-misses

This commit is contained in:
Patrick Haßel 2025-06-05 21:48:54 +02:00
parent f7afaa05f7
commit 68efa17092
2 changed files with 15 additions and 2 deletions

View File

@ -13,7 +13,9 @@
bool audioMute = false;
float audioVolume = 0.05;
float audioVolume = 0.1;
int copyErrors = 0;
AudioBoardStream board(AudioKitEs8388V1);
@ -40,6 +42,7 @@ void audioStop() {
running = false;
Serial.println("[STOP]");
}
copyErrors = 0;
copier.end();
mp3Stream.end();
mp3Decoder.end();
@ -193,12 +196,20 @@ void audioSetup() {
bool audioLoop() {
audioVolume = max(0.0f, min(audioVolume, 1.0f));
board.setVolume(audioVolume);
if (abs(board.volume() - audioVolume) >= 0.01f) {
Serial.println("writing new volume...");
board.setVolume(audioVolume);
}
board.setMute(audioMute);
if (copier.copy() > 0) {
copyErrors = 0;
return true;
}
if (running) {
copyErrors++;
if (copyErrors < 100) {
return true;
}
Serial.println("Stream ended!");
audioStop();
}

View File

@ -13,6 +13,8 @@ void setup() {
playerSetup();
playlistClear();
playlistAdd("ICY|http://liveradio.sr.de/sr/sr1/mp3/128/stream.mp3|SR1");
playlistAdd("ICY|http://uk3.internet-radio.com:8082/live|1940s Radio");
playlistAdd("ICY|https://das-edge16-live365-dal02.cdnstream.com/a22508|Mistletoe Radio");
playlistAdd("ICY|https://stream.rockantenne.de/rockantenne/stream/mp3|Rockantenne Classic Perlen");
wifiLoop();