From 144a91cace5a6342179a9d20804768123b548dfa Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 23 Jan 2009 00:06:54 +0100 Subject: [PATCH] playlist: moved code to playlist_queue_song_order() Merged duplicate code from queueNextSongInPlaylist(). --- src/playlist.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 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 +playlist_queue_song_order(unsigned order) +{ + struct song *song; + char *uri; + + assert(queue_valid_order(&playlist.queue, order)); + + playlist.queued = order; + + 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)) { - struct song *song; - char *uri; - - playlist.queued = playlist.current + 1; - - 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(playlist.current + 1); } else if (!queue_is_empty(&playlist.queue) && playlist.queue.repeat) { - struct song *song; - char *uri; - 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); } }