summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-10-23 16:35:59 +0200
committerGravatar waker <wakeroid@gmail.com>2011-10-23 16:35:59 +0200
commit7c7436da5f2e7d230e379c444c77298b99ed90ac (patch)
treeb8b867bc88e7805bcecca58fcb81879d40a7cab8
parent50208fdf54d7afaf8b42abc511ddc675b9475184 (diff)
after switching to shuffle-albums mode, while playing a track, mark all previous album tracks as played
-rw-r--r--playlist.c8
-rw-r--r--streamer.c24
-rw-r--r--streamer.h3
3 files changed, 33 insertions, 2 deletions
diff --git a/playlist.c b/playlist.c
index f83cc480..3a2ebf45 100644
--- a/playlist.c
+++ b/playlist.c
@@ -105,7 +105,7 @@ static playlist_t dummy_playlist = {
.refc = 1
};
-static int pl_order; // mirrors "playback.order" config variable
+static int pl_order = -1; // mirrors "playback.order" config variable
static int no_remove_notify;
@@ -113,12 +113,16 @@ static playlist_t *addfiles_playlist; // current playlist for adding files/folde
void
pl_set_order (int order) {
- if (pl_order != order || pl_order == PLAYBACK_ORDER_SHUFFLE_TRACKS || pl_order == PLAYBACK_ORDER_SHUFFLE_ALBUMS) {
+ int prev_order = pl_order;
+
+ if (pl_order != order) {
pl_order = order;
for (playlist_t *plt = playlists_head; plt; plt = plt->next) {
plt_reshuffle (plt, NULL, NULL);
}
}
+
+ streamer_notify_order_changed (prev_order, pl_order);
}
int
diff --git a/streamer.c b/streamer.c
index e5aecfa3..cfb61090 100644
--- a/streamer.c
+++ b/streamer.c
@@ -2243,3 +2243,27 @@ void
streamer_get_output_format (ddb_waveformat_t *fmt) {
memcpy (fmt, &output_format, sizeof (ddb_waveformat_t));
}
+
+void
+streamer_notify_order_changed (int prev_order, int new_order) {
+ if (prev_order != PLAYBACK_ORDER_SHUFFLE_ALBUMS && new_order == PLAYBACK_ORDER_SHUFFLE_ALBUMS) {
+ streamer_lock ();
+ playItem_t *curr = playing_track;
+ if (curr) {
+
+ const char *alb = pl_find_meta_raw (curr, "album");
+ const char *art = pl_find_meta_raw (curr, "artist");
+ playItem_t *next = curr->prev[PL_MAIN];
+ while (next) {
+ if (alb == pl_find_meta_raw (next, "album") && art == pl_find_meta_raw (next, "artist")) {
+ next->played = 1;
+ next = next->prev[PL_MAIN];
+ }
+ else {
+ break;
+ }
+ }
+ }
+ streamer_unlock ();
+ }
+}
diff --git a/streamer.h b/streamer.h
index a0414e46..8703c661 100644
--- a/streamer.h
+++ b/streamer.h
@@ -127,4 +127,7 @@ streamer_dsp_postinit (void);
int
streamer_dsp_chain_save (const char *fname, ddb_dsp_context_t *chain);
+void
+streamer_notify_order_changed (int prev_order, int new_order);
+
#endif // __STREAMER_H