diff options
author | Max Kellermann <max@musicpd.org> | 2017-10-17 19:02:41 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-10-18 09:05:24 +0200 |
commit | 0f79287b04602ce92cb86c056f78d5f70ab71d42 (patch) | |
tree | 21c627f7422503241ff968c2ffdbde96b23dacdc /src/queue/PlaylistControl.cxx | |
parent | f2fac77d8c6ae42ce2e9a67dcfde4085ec44cfdf (diff) |
queue/Playlist: move code to MoveOrderToCurrent()
Diffstat (limited to 'src/queue/PlaylistControl.cxx')
-rw-r--r-- | src/queue/PlaylistControl.cxx | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/queue/PlaylistControl.cxx b/src/queue/PlaylistControl.cxx index 99012aedf..c2284b60c 100644 --- a/src/queue/PlaylistControl.cxx +++ b/src/queue/PlaylistControl.cxx @@ -56,6 +56,24 @@ playlist::Stop(PlayerControl &pc) } } +unsigned +playlist::MoveOrderToCurrent(unsigned old_order) +{ + if (!queue.random) + /* no-op because there is no order list */ + return old_order; + + const unsigned destination_order = playing + ? (unsigned)current + : 0; + + /* swap the new song with the previous "current" one, so + playback continues as planned */ + queue.SwapOrders(old_order, destination_order); + + return destination_order; +} + void playlist::PlayPosition(PlayerControl &pc, int song) { @@ -90,13 +108,7 @@ playlist::PlayPosition(PlayerControl &pc, int song) number, because random mode is enabled */ i = queue.PositionToOrder(song); - if (!playing) - current = 0; - - /* swap the new song with the previous "current" one, - so playback continues as planned */ - queue.SwapOrders(i, current); - i = current; + i = MoveOrderToCurrent(i); } stop_on_error = false; |