From 0626f80fd21fb224ae695e40efc4561e537a8847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laszlo=20Heged=C3=BCs?= Date: Thu, 7 Dec 2023 20:31:11 +0100 Subject: [PATCH] Fix webstream playlist abort when track fails When the webstream connects but is redirected to a 404 page, we should not abort the playlist but jump to the next entry. --- src/AudioPlayer.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/AudioPlayer.cpp b/src/AudioPlayer.cpp index a883d514f..de27622d7 100644 --- a/src/AudioPlayer.cpp +++ b/src/AudioPlayer.cpp @@ -132,7 +132,7 @@ void AudioPlayer_Init(void) { xTaskCreatePinnedToCore( AudioPlayer_Task, /* Function to implement the task */ "mp3play", /* Name of the task */ - 6000, /* Stack size in words */ + 8192, /* Stack size in words */ NULL, /* Task input parameter */ 2 | portPRIVILEGE_BIT, /* Priority of the task */ &AudioTaskHandle, /* Task handle. */ @@ -352,7 +352,9 @@ void AudioPlayer_Task(void *parameter) { audio->setI2SCommFMT_LSB(true); #endif - uint8_t settleCount = 0; + constexpr uint32_t playbackTimeout = 2000; + uint32_t playbackTimeoutStart = 0; + AudioPlayer_CurrentVolume = AudioPlayer_GetInitVolume(); audio->setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); audio->setVolume(AudioPlayer_CurrentVolume, VOLUMECURVE); @@ -832,15 +834,16 @@ void AudioPlayer_Task(void *parameter) { } if (audio->isRunning()) { - settleCount = 0; + playbackTimeoutStart = millis(); } - // If error occured: remove playlist from ESPuino + // If error occured: move to the next track in the playlist if (gPlayProperties.playMode != NO_PLAYLIST && gPlayProperties.playMode != BUSY && !audio->isRunning() && !gPlayProperties.pausePlay) { - if (settleCount++ == 50) { // Hack to give audio some time to settle down after playlist was generated - gPlayProperties.playlistFinished = true; - gPlayProperties.playMode = NO_PLAYLIST; - settleCount = 0; + if ((millis() - playbackTimeoutStart) > playbackTimeout) { + // Audio playback timed out, move on to the next + System_IndicateError(); + gPlayProperties.trackFinished = true; + playbackTimeoutStart = millis(); } } if ((System_GetOperationMode() == OPMODE_BLUETOOTH_SOURCE) && audio->isRunning()) {