commit - 805c96fb4b4e3b14dcf623e029fef265a5601836
commit + 13b838834600a04758caef4fae2f1ab61cd357d2
blob - ecebe462e172d3998394f107fc495bf4dd088ae6
blob + 1eebcee3c871c31f5bbda5c71f86ce45c82ac7b5
--- amused.c
+++ amused.c
switch (imsg.hdr.type) {
case IMSG_ERR:
- /* TODO: remove current track from the playlist */
+ playlist_dropcurrent();
+ /* fallthrough */
case IMSG_EOF:
main_playlist_advance();
break;
+
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
if (main_play_song(song))
break;
- /* TODO: remove the song from the playlist */
+ playlist_dropcurrent();
}
}
if (main_play_song(song))
return;
- /* TODO: remove the song from the playlist */
+ playlist_dropcurrent();
main_playlist_advance();
}
blob - c94f708c54094dff1a108faba7a287ecd3b187ab
blob + c8931b7db81980b7e55d276290bc9d1093b72de6
--- playlist.c
+++ playlist.c
playlist.cap = 0;
play_off = -1;
}
+
+void
+playlist_dropcurrent(void)
+{
+ size_t i;
+
+ if (play_off == -1 || playlist.len == 0)
+ return;
+
+ free(playlist.songs[play_off]);
+
+ playlist.len--;
+ for (i = play_off; i < playlist.len; ++i)
+ playlist.songs[i] = playlist.songs[i+1];
+
+ playlist.songs[playlist.len] = NULL;
+}
blob - 3b2e2ed26d78dceb8e3fa7c637cb95218fedc322
blob + 3f4ea37cca318baf7e9b932e6232fa814d018c4f
--- playlist.h
+++ playlist.h
const char *playlist_advance(void);
void playlist_reset(void);
void playlist_truncate(void);
+void playlist_dropcurrent(void);
#endif