summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-02-26 14:44:52 +0100
committerLars-Dominik Braun <lars@6xq.net>2011-02-26 14:44:52 +0100
commitc225eea4edfb8cf8ede845cc6f9b7e858aabe6e8 (patch)
treeca4a3ed13d1e31a211a997641e50cac79cb6df21 /src/main.c
parenta79a0c3fb812efac3370c6ed73d37bb8fd1d318e (diff)
downloadpianobar-c225eea4edfb8cf8ede845cc6f9b7e858aabe6e8.tar.gz
pianobar-c225eea4edfb8cf8ede845cc6f9b7e858aabe6e8.tar.bz2
pianobar-c225eea4edfb8cf8ede845cc6f9b7e858aabe6e8.zip
Always add song to history
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c38
1 files changed, 3 insertions, 35 deletions
diff --git a/src/main.c b/src/main.c
index 3104898..6886afc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -157,40 +157,6 @@ static void BarMainHandleUserInput (BarApp_t *app) {
}
}
-/* append current song to history list and move to the next song
- */
-static void BarMainNextSong (BarApp_t *app) {
- if (app->settings.history != 0) {
- /* prepend song to history list */
- PianoSong_t *tmpSong = app->songHistory;
- app->songHistory = app->playlist;
- /* select next song */
- app->playlist = app->playlist->next;
- app->songHistory->next = tmpSong;
-
- /* limit history's length */
- /* start with 1, so we're stopping at n-1 and have the
- * chance to set ->next = NULL */
- unsigned int i = 1;
- tmpSong = app->songHistory;
- while (i < app->settings.history && tmpSong != NULL) {
- tmpSong = tmpSong->next;
- ++i;
- }
- /* if too many songs in history... */
- if (tmpSong != NULL) {
- PianoSong_t *delSong = tmpSong->next;
- tmpSong->next = NULL;
- if (delSong != NULL) {
- PianoDestroyPlaylist (delSong);
- }
- }
- } else {
- /* don't keep history */
- app->playlist = app->playlist->next;
- }
-}
-
/* fetch new playlist
*/
static void BarMainGetPlaylist (BarApp_t *app) {
@@ -338,7 +304,9 @@ static void BarMainLoop (BarApp_t *app) {
if (app->curStation != NULL) {
/* what's next? */
if (app->playlist != NULL) {
- BarMainNextSong (app);
+ PianoSong_t *histsong = app->playlist;
+ app->playlist = app->playlist->next;
+ BarUiHistoryPrepend (app, histsong);
}
if (app->playlist == NULL) {
BarMainGetPlaylist (app);