Merge branch 'v0.20.x'

This commit is contained in:
Max Kellermann
2017-12-03 16:22:08 +01:00
12 changed files with 47 additions and 15 deletions

View File

@@ -75,8 +75,7 @@ playlist::MoveOrderToCurrent(unsigned old_order)
} else {
/* not playing anything: move the specified song to
the front */
queue.SwapOrders(old_order, 0);
return 0;
return queue.MoveOrderBefore(old_order, 0);
}
}

View File

@@ -112,7 +112,7 @@ playlist::AppendSong(PlayerControl &pc, DetachedSong &&song)
else
start = current + 1;
if (start < queue.GetLength())
queue.ShuffleOrderLast(start, queue.GetLength());
queue.ShuffleOrderLastWithPriority(start, queue.GetLength());
}
UpdateQueuedSong(pc, queued_song);

View File

@@ -359,8 +359,20 @@ Queue::ShuffleOrderFirst(unsigned start, unsigned end) noexcept
}
void
Queue::ShuffleOrderLast(unsigned start, unsigned end) noexcept
Queue::ShuffleOrderLastWithPriority(unsigned start, unsigned end) noexcept
{
assert(end <= length);
assert(start < end);
/* skip all items at the start which have a higher priority,
because the last item shall only be shuffled within its
priority group */
const auto last_priority = items[OrderToPosition(end - 1)].priority;
while (items[OrderToPosition(start)].priority != last_priority) {
++start;
assert(start < end);
}
rand.AutoCreate();
std::uniform_int_distribution<unsigned> distribution(start, end - 1);

View File

@@ -357,11 +357,12 @@ struct Queue {
void ShuffleOrderFirst(unsigned start, unsigned end) noexcept;
/**
* Shuffles the virtual order of the last song in the specified
* (order) range. This is used in random mode after a song has been
* appended by queue_append().
* Shuffles the virtual order of the last song in the
* specified (order) range; only songs which match this song's
* priority are considered. This is used in random mode after
* a song has been appended by Append().
*/
void ShuffleOrderLast(unsigned start, unsigned end) noexcept;
void ShuffleOrderLastWithPriority(unsigned start, unsigned end) noexcept;
/**
* Shuffles a (position) range in the queue. The songs are physically