copyErrors: be more robust against occasional copier.copy-misses
This commit is contained in:
parent
f7afaa05f7
commit
68efa17092
@ -13,7 +13,9 @@
|
|||||||
|
|
||||||
bool audioMute = false;
|
bool audioMute = false;
|
||||||
|
|
||||||
float audioVolume = 0.05;
|
float audioVolume = 0.1;
|
||||||
|
|
||||||
|
int copyErrors = 0;
|
||||||
|
|
||||||
AudioBoardStream board(AudioKitEs8388V1);
|
AudioBoardStream board(AudioKitEs8388V1);
|
||||||
|
|
||||||
@ -40,6 +42,7 @@ void audioStop() {
|
|||||||
running = false;
|
running = false;
|
||||||
Serial.println("[STOP]");
|
Serial.println("[STOP]");
|
||||||
}
|
}
|
||||||
|
copyErrors = 0;
|
||||||
copier.end();
|
copier.end();
|
||||||
mp3Stream.end();
|
mp3Stream.end();
|
||||||
mp3Decoder.end();
|
mp3Decoder.end();
|
||||||
@ -193,12 +196,20 @@ void audioSetup() {
|
|||||||
|
|
||||||
bool audioLoop() {
|
bool audioLoop() {
|
||||||
audioVolume = max(0.0f, min(audioVolume, 1.0f));
|
audioVolume = max(0.0f, min(audioVolume, 1.0f));
|
||||||
|
if (abs(board.volume() - audioVolume) >= 0.01f) {
|
||||||
|
Serial.println("writing new volume...");
|
||||||
board.setVolume(audioVolume);
|
board.setVolume(audioVolume);
|
||||||
|
}
|
||||||
board.setMute(audioMute);
|
board.setMute(audioMute);
|
||||||
if (copier.copy() > 0) {
|
if (copier.copy() > 0) {
|
||||||
|
copyErrors = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (running) {
|
if (running) {
|
||||||
|
copyErrors++;
|
||||||
|
if (copyErrors < 100) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Serial.println("Stream ended!");
|
Serial.println("Stream ended!");
|
||||||
audioStop();
|
audioStop();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,8 @@ void setup() {
|
|||||||
playerSetup();
|
playerSetup();
|
||||||
playlistClear();
|
playlistClear();
|
||||||
playlistAdd("ICY|http://liveradio.sr.de/sr/sr1/mp3/128/stream.mp3|SR1");
|
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");
|
playlistAdd("ICY|https://stream.rockantenne.de/rockantenne/stream/mp3|Rockantenne Classic Perlen");
|
||||||
|
|
||||||
wifiLoop();
|
wifiLoop();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user