queue/Playlist: don't let StaleSong() interrupt playback

http://bugs.musicpd.org/view.php?id=4470
This commit is contained in:
Max Kellermann 2016-03-18 18:08:13 +01:00
parent f37a1026f9
commit 1543dd85b5
1 changed files with 9 additions and 1 deletions

View File

@ -312,8 +312,16 @@ playlist::DeleteId(PlayerControl &pc, unsigned id)
void
playlist::StaleSong(PlayerControl &pc, const char *uri)
{
/* don't remove the song if it's currently being played, to
avoid disrupting playback; a deleted file may still be
played if it's still open */
// TODO: mark the song as "stale" and postpone deletion
int current_position = playing
? GetCurrentPosition()
: -1;
for (int i = queue.GetLength() - 1; i >= 0; --i)
if (queue.Get(i).IsURI(uri))
if (i != current_position && queue.Get(i).IsURI(uri))
DeletePosition(pc, i);
}