aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-23 00:06:54 +0100
committerMax Kellermann <max@duempel.org>2009-01-23 00:06:54 +0100
commit144a91cace5a6342179a9d20804768123b548dfa (patch)
tree8661dbabcea0cd84a9ac155567e69eaf88b686a3 /src/playlist.c
parent9d3c14830b71ca62a2ec3b8de4368fcff20bb9cf (diff)
downloadmpd-144a91cace5a6342179a9d20804768123b548dfa.tar.gz
mpd-144a91cace5a6342179a9d20804768123b548dfa.tar.xz
mpd-144a91cace5a6342179a9d20804768123b548dfa.zip
playlist: moved code to playlist_queue_song_order()
Merged duplicate code from queueNextSongInPlaylist().
Diffstat (limited to 'src/playlist.c')
-rw-r--r--src/playlist.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/playlist.c b/src/playlist.c
index fd46d0fa9..3f18f6b81 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -391,37 +391,34 @@ static void swapSongs(unsigned song1, unsigned song2)
queue_swap(&playlist.queue, song1, song2);
}
-static void queueNextSongInPlaylist(void)
+static void
+playlist_queue_song_order(unsigned order)
{
- if (playlist.current + 1 < (int)queue_length(&playlist.queue)) {
- struct song *song;
- char *uri;
+ struct song *song;
+ char *uri;
- playlist.queued = playlist.current + 1;
+ assert(queue_valid_order(&playlist.queue, order));
- song = queue_get_order(&playlist.queue, playlist.queued);
- uri = song_get_uri(song);
- g_debug("playlist: queue song %i:\"%s\"",
- playlist.queued, uri);
- g_free(uri);
+ playlist.queued = order;
- queueSong(song);
- } else if (!queue_is_empty(&playlist.queue) && playlist.queue.repeat) {
- struct song *song;
- char *uri;
+ song = queue_get_order(&playlist.queue, order);
+ uri = song_get_uri(song);
+ g_debug("playlist: queue song %i:\"%s\"",
+ playlist.queued, uri);
+ g_free(uri);
+ queueSong(song);
+}
+
+static void queueNextSongInPlaylist(void)
+{
+ if (playlist.current + 1 < (int)queue_length(&playlist.queue)) {
+ playlist_queue_song_order(playlist.current + 1);
+ } else if (!queue_is_empty(&playlist.queue) && playlist.queue.repeat) {
if (queue_length(&playlist.queue) > 1 && playlist.queue.random)
randomizeOrder(0, queue_length(&playlist.queue) - 1);
- playlist.queued = 0;
-
- song = queue_get_order(&playlist.queue, playlist.queued);
- uri = song_get_uri(song);
- g_debug("playlist: queue song %i:\"%s\"",
- playlist.queued, uri);
- g_free(uri);
-
- queueSong(song);
+ playlist_queue_song_order(0);
}
}