From 7aa1dceef6032b6772bbebf9e8d766acaadf569d Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Mon, 29 Oct 2018 12:01:17 +0100
Subject: [PATCH] player/Control: move IDLE_PLAYER to Player::SeekDecoder()

This emits the event even if PlayerControl::Play() is used to replay
the current song, which emits the missing "player" idle event.

Closes #381
---
 NEWS                   | 2 ++
 src/player/Control.cxx | 8 ++------
 src/player/Thread.cxx  | 2 ++
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index db8cdb497..ffb1a2ef2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,6 @@
 ver 0.20.23 (not yet released)
+* protocol
+  - emit "player" idle event when restarting the current song
 * new clang crash bug workaround
 
 ver 0.20.22 (2018/10/23)
diff --git a/src/player/Control.cxx b/src/player/Control.cxx
index 013b57bf5..0c18a09fa 100644
--- a/src/player/Control.cxx
+++ b/src/player/Control.cxx
@@ -246,12 +246,8 @@ PlayerControl::LockSeek(DetachedSong *song, SongTime t)
 {
 	assert(song != nullptr);
 
-	{
-		const std::lock_guard<Mutex> protect(mutex);
-		SeekLocked(song, t);
-	}
-
-	idle_add(IDLE_PLAYER);
+	const std::lock_guard<Mutex> protect(mutex);
+	SeekLocked(song, t);
 }
 
 void
diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx
index fcb7b39da..001c96fa1 100644
--- a/src/player/Thread.cxx
+++ b/src/player/Thread.cxx
@@ -580,6 +580,8 @@ Player::SeekDecoder()
 {
 	assert(pc.next_song != nullptr);
 
+	idle_add(IDLE_PLAYER);
+
 	pc.outputs.Cancel();
 
 	const SongTime start_time = pc.next_song->GetStartTime();