From 4404f20cf47e8c9c7f850955a9838d4b353f41fd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Nov 2015 17:31:32 +0100 Subject: player/Control: Seek*() returns Error information --- src/player/Control.cxx | 19 +++++++++++++++---- src/player/Control.hxx | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src/player') diff --git a/src/player/Control.cxx b/src/player/Control.cxx index 4c30159ba..6c78290cf 100644 --- a/src/player/Control.cxx +++ b/src/player/Control.cxx @@ -204,8 +204,8 @@ PlayerControl::LockEnqueueSong(DetachedSong *song) EnqueueSongLocked(song); } -void -PlayerControl::SeekLocked(DetachedSong *song, SongTime t) +bool +PlayerControl::SeekLocked(DetachedSong *song, SongTime t, Error &error_r) { assert(song != nullptr); @@ -214,21 +214,32 @@ PlayerControl::SeekLocked(DetachedSong *song, SongTime t) assert(next_song == nullptr); + ClearError(); next_song = song; seek_time = t; SynchronousCommand(PlayerCommand::SEEK); assert(next_song == nullptr); + + if (error_type != PlayerError::NONE) { + assert(error.IsDefined()); + error_r.Set(error); + return false; + } + + assert(!error.IsDefined()); + return true; } bool -PlayerControl::LockSeek(DetachedSong *song, SongTime t) +PlayerControl::LockSeek(DetachedSong *song, SongTime t, Error &error_r) { assert(song != nullptr); { const ScopeLock protect(mutex); - SeekLocked(song, t); + if (!SeekLocked(song, t, error_r)) + return false; } idle_add(IDLE_PLAYER); diff --git a/src/player/Control.hxx b/src/player/Control.hxx index df2dc35be..5e7fcbdb7 100644 --- a/src/player/Control.hxx +++ b/src/player/Control.hxx @@ -425,7 +425,7 @@ private: SynchronousCommand(PlayerCommand::QUEUE); } - void SeekLocked(DetachedSong *song, SongTime t); + bool SeekLocked(DetachedSong *song, SongTime t, Error &error_r); public: /** @@ -442,7 +442,7 @@ public: * @return true on success, false on failure (e.g. if MPD isn't * playing currently) */ - bool LockSeek(DetachedSong *song, SongTime t); + bool LockSeek(DetachedSong *song, SongTime t, Error &error_r); void SetCrossFade(float cross_fade_seconds); -- cgit v1.2.3