diff --git a/src/Partition.cxx b/src/Partition.cxx index 63ce07f2e..1c2f646dc 100644 --- a/src/Partition.cxx +++ b/src/Partition.cxx @@ -183,6 +183,12 @@ Partition::OnQueueSongStarted() noexcept EmitIdle(IDLE_PLAYER); } +void +Partition::OnPlayerError() noexcept +{ + EmitIdle(IDLE_PLAYER); +} + void Partition::OnPlayerSync() noexcept { diff --git a/src/Partition.hxx b/src/Partition.hxx index 7679b5879..9a841cdf9 100644 --- a/src/Partition.hxx +++ b/src/Partition.hxx @@ -277,6 +277,7 @@ private: void OnQueueSongStarted() noexcept override; /* virtual methods from class PlayerListener */ + void OnPlayerError() noexcept override; void OnPlayerSync() noexcept override; void OnPlayerTagModified() noexcept override; void OnBorderPause() noexcept override; diff --git a/src/player/Control.cxx b/src/player/Control.cxx index 5e919aa1f..3bc4a75f7 100644 --- a/src/player/Control.cxx +++ b/src/player/Control.cxx @@ -19,6 +19,7 @@ #include "Control.hxx" #include "Outputs.hxx" +#include "Listener.hxx" #include "Idle.hxx" #include "song/DetachedSong.hxx" @@ -190,6 +191,9 @@ PlayerControl::SetError(PlayerError type, std::exception_ptr &&_error) noexcept error_type = type; error = std::move(_error); + + // TODO: is it ok to call this while holding mutex lock? + listener.OnPlayerError(); } void diff --git a/src/player/Listener.hxx b/src/player/Listener.hxx index 83721862a..42254b85f 100644 --- a/src/player/Listener.hxx +++ b/src/player/Listener.hxx @@ -22,6 +22,12 @@ class PlayerListener { public: + /** + * A playback error has occurred and + * PlayerControl::CheckRethrowError() will provide details. + */ + virtual void OnPlayerError() noexcept = 0; + /** * Must call playlist_sync(). */ diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index e06cc414f..9045b5d12 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -575,8 +575,6 @@ Player::OpenOutput() noexcept pc.SetOutputError(std::current_exception()); - idle_add(IDLE_PLAYER); - return false; } @@ -1065,8 +1063,6 @@ Player::PlayNextChunk() noexcept pc.LockSetOutputError(std::current_exception()); - idle_add(IDLE_PLAYER); - return false; }