aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-11-11 17:31:32 +0100
committerMax Kellermann <max@duempel.org>2015-11-11 19:56:09 +0100
commit4404f20cf47e8c9c7f850955a9838d4b353f41fd (patch)
treef7101d67e826fa6cbf59e0cb6af5e3c10a13a497 /src
parentfaca8bc02a67ed06e60a4d827d5d7bb69027b4f3 (diff)
downloadmpd-4404f20cf47e8c9c7f850955a9838d4b353f41fd.tar.gz
mpd-4404f20cf47e8c9c7f850955a9838d4b353f41fd.tar.xz
mpd-4404f20cf47e8c9c7f850955a9838d4b353f41fd.zip
player/Control: Seek*() returns Error information
Diffstat (limited to 'src')
-rw-r--r--src/player/Control.cxx19
-rw-r--r--src/player/Control.hxx4
-rw-r--r--src/queue/PlaylistControl.cxx6
3 files changed, 18 insertions, 11 deletions
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);
diff --git a/src/queue/PlaylistControl.cxx b/src/queue/PlaylistControl.cxx
index f7b2b16a3..7ed19fbfb 100644
--- a/src/queue/PlaylistControl.cxx
+++ b/src/queue/PlaylistControl.cxx
@@ -211,12 +211,8 @@ playlist::SeekSongOrder(PlayerControl &pc, unsigned i, SongTime seek_time,
queued_song = nullptr;
}
- if (!pc.LockSeek(new DetachedSong(queue.GetOrder(i)), seek_time)) {
+ if (!pc.LockSeek(new DetachedSong(queue.GetOrder(i)), seek_time, error)) {
UpdateQueuedSong(pc, queued_song);
-
- // TODO: fix error code
- error.Set(playlist_domain, int(PlaylistResult::NOT_PLAYING),
- "Decoder failed to seek");
return false;
}