commit b21ec899d80b2b7298539334801e73b617cbea3c from: Omar Polo date: Sat Feb 19 10:16:25 2022 UTC update the heuristic: try to keep `current_song', not play_off commit - 74c987d53230b125b919cd1ab99426e6d81a8bbc commit + b21ec899d80b2b7298539334801e73b617cbea3c blob - 5db3aae35675d0a73a6f4c8dbe5ddaa4c4cff778 blob + 6ccf4af90ec82bcacd45ac2884c4c5a0dd73be5e --- playlist.c +++ playlist.c @@ -49,23 +49,21 @@ playlist_swap(struct playlist *p) { ssize_t i = -1; - if (play_off != -1) { + if (current_song != NULL) { /* try to adjust play_off to match the same song */ for (i = 0; i < p->len; ++i) { - if (!strcmp(playlist.songs[play_off], p->songs[i])) + if (!strcmp(current_song, p->songs[i])) break; } /* try to match one song before */ if (i == p->len && play_off >= 1) for (i = 0; i < p->len; ++i) - if (!strcmp(playlist.songs[play_off-1], - p->songs[i])) + if (!strcmp(current_song, p->songs[i])) break; /* or one song after */ if (i == p->len && play_off < playlist.len-1) for (i = 0; i < p->len; ++i) - if (!strcmp(playlist.songs[play_off+1], - p->songs[i])) + if (!strcmp(current_song, p->songs[i])) break; if (i == p->len) i = -1;