Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix M3U playlist abort #276

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/AudioPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,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);
Expand Down Expand Up @@ -827,15 +829,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()) {
Expand Down