From 5186c0fdb67ff60600d81917b589826c0547255a Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Sun, 7 Apr 2024 21:23:01 +0200 Subject: [PATCH] autoplaylist bugfix for playlists with only one preset * prevent infinite loop in case that there is only one preset in a playlist * fixing two typos --- .../usermod_v2_auto_playlist/usermod_v2_auto_playlist.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h b/usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h index 74c6472d..0e420eae 100644 --- a/usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h +++ b/usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h @@ -138,7 +138,7 @@ class AutoPlaylistUsermod : public Usermod { // Make the analysis less sensitive if we miss the window. // Sometimes the analysis lowers the change_threshold too much for // the current music, especially after track changes or during - // sparce intros and breakdowns. + // sparse intros and breakdowns. if (change_interval > ideal_change_min && distance_tracker <= 100) { @@ -149,7 +149,7 @@ class AutoPlaylistUsermod : public Usermod { if (functionality_enabled) { #ifdef USERMOD_AUTO_PLAYLIST_DEBUG - USER_PRINTF("--- lowest distance = %4lu - no changes done in %6ldms - next change_threshold is %4u (%4u diff aprox)\n", (unsigned long)distance_tracker,change_interval,change_threshold,change_threshold_change); + USER_PRINTF("--- lowest distance = %4lu - no changes done in %6ldms - next change_threshold is %4u (%4u diff approx)\n", (unsigned long)distance_tracker,change_interval,change_threshold,change_threshold_change); #endif } @@ -205,7 +205,7 @@ class AutoPlaylistUsermod : public Usermod { do { newpreset = autoChangeIds.at(random(0, autoChangeIds.size())); // random() is *exclusive* of the last value, so it's OK to use the full size. - } while (currentPreset == newpreset); // make sure we get a different random preset. + } while ((currentPreset == newpreset) && (autoChangeIds.size() > 1)); // make sure we get a different random preset. Unless there is only one. if (change_interval > change_lockout+3) {