Skip to content

Commit 5186c0f

Browse files
committed
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
1 parent 1ca7faf commit 5186c0f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

usermods/usermod_v2_auto_playlist/usermod_v2_auto_playlist.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class AutoPlaylistUsermod : public Usermod {
138138
// Make the analysis less sensitive if we miss the window.
139139
// Sometimes the analysis lowers the change_threshold too much for
140140
// the current music, especially after track changes or during
141-
// sparce intros and breakdowns.
141+
// sparse intros and breakdowns.
142142

143143
if (change_interval > ideal_change_min && distance_tracker <= 100) {
144144

@@ -149,7 +149,7 @@ class AutoPlaylistUsermod : public Usermod {
149149

150150
if (functionality_enabled) {
151151
#ifdef USERMOD_AUTO_PLAYLIST_DEBUG
152-
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);
152+
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);
153153
#endif
154154
}
155155

@@ -205,7 +205,7 @@ class AutoPlaylistUsermod : public Usermod {
205205

206206
do {
207207
newpreset = autoChangeIds.at(random(0, autoChangeIds.size())); // random() is *exclusive* of the last value, so it's OK to use the full size.
208-
} while (currentPreset == newpreset); // make sure we get a different random preset.
208+
} while ((currentPreset == newpreset) && (autoChangeIds.size() > 1)); // make sure we get a different random preset. Unless there is only one.
209209

210210
if (change_interval > change_lockout+3) {
211211

0 commit comments

Comments
 (0)