From 12b6959ea201fea925c4376f961b8d54738292e2 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Wed, 26 Nov 2014 08:54:16 +0100
Subject: [PATCH] Playlist: reset song priority on playback

A priority should be a volatile thing: it should schedule a song for
playing back once, but it should not affect the next time the queue
gets played.
---
 NEWS                   | 1 +
 doc/protocol.xml       | 3 ++-
 src/queue/Playlist.cxx | 4 ++++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 1e87c7d14..d20fe868c 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ ver 0.20 (not yet released)
   - ape: drop support for non-standard tag "album artist"
 * output
   - pulse: set channel map to WAVE-EX
+* reset song priority on playback
 
 ver 0.19.5 (not yet released)
 * decoder
diff --git a/doc/protocol.xml b/doc/protocol.xml
index 549b82c6c..2d5979a5f 100644
--- a/doc/protocol.xml
+++ b/doc/protocol.xml
@@ -240,7 +240,8 @@
         bigger than the priority of the current song.  Decreasing the
         priority of a song will moved it farther to the end of the
         sequence.  Changing the priority of the current song has no
-        effect on the sequence.
+        effect on the sequence.  During playback, a song's priority is
+        reset to zero.
       </para>
     </section>
   </chapter>
diff --git a/src/queue/Playlist.cxx b/src/queue/Playlist.cxx
index 4419d6e6e..60588ab90 100644
--- a/src/queue/Playlist.cxx
+++ b/src/queue/Playlist.cxx
@@ -64,6 +64,10 @@ void
 playlist::SongStarted()
 {
 	assert(current >= 0);
+
+	/* reset a song's "priority" when playback starts */
+	if (queue.SetPriority(queue.OrderToPosition(current), 0, -1, false))
+		OnModified();
 }
 
 inline void