player/Control: Seek*() returns Error information

This commit is contained in:
Max Kellermann 2015-11-11 17:31:32 +01:00
parent faca8bc02a
commit 4404f20cf4
3 changed files with 18 additions and 11 deletions

View File

@ -204,8 +204,8 @@ PlayerControl::LockEnqueueSong(DetachedSong *song)
EnqueueSongLocked(song); EnqueueSongLocked(song);
} }
void bool
PlayerControl::SeekLocked(DetachedSong *song, SongTime t) PlayerControl::SeekLocked(DetachedSong *song, SongTime t, Error &error_r)
{ {
assert(song != nullptr); assert(song != nullptr);
@ -214,21 +214,32 @@ PlayerControl::SeekLocked(DetachedSong *song, SongTime t)
assert(next_song == nullptr); assert(next_song == nullptr);
ClearError();
next_song = song; next_song = song;
seek_time = t; seek_time = t;
SynchronousCommand(PlayerCommand::SEEK); SynchronousCommand(PlayerCommand::SEEK);
assert(next_song == nullptr); assert(next_song == nullptr);
if (error_type != PlayerError::NONE) {
assert(error.IsDefined());
error_r.Set(error);
return false;
}
assert(!error.IsDefined());
return true;
} }
bool bool
PlayerControl::LockSeek(DetachedSong *song, SongTime t) PlayerControl::LockSeek(DetachedSong *song, SongTime t, Error &error_r)
{ {
assert(song != nullptr); assert(song != nullptr);
{ {
const ScopeLock protect(mutex); const ScopeLock protect(mutex);
SeekLocked(song, t); if (!SeekLocked(song, t, error_r))
return false;
} }
idle_add(IDLE_PLAYER); idle_add(IDLE_PLAYER);

View File

@ -425,7 +425,7 @@ private:
SynchronousCommand(PlayerCommand::QUEUE); SynchronousCommand(PlayerCommand::QUEUE);
} }
void SeekLocked(DetachedSong *song, SongTime t); bool SeekLocked(DetachedSong *song, SongTime t, Error &error_r);
public: public:
/** /**
@ -442,7 +442,7 @@ public:
* @return true on success, false on failure (e.g. if MPD isn't * @return true on success, false on failure (e.g. if MPD isn't
* playing currently) * playing currently)
*/ */
bool LockSeek(DetachedSong *song, SongTime t); bool LockSeek(DetachedSong *song, SongTime t, Error &error_r);
void SetCrossFade(float cross_fade_seconds); void SetCrossFade(float cross_fade_seconds);

View File

@ -211,12 +211,8 @@ playlist::SeekSongOrder(PlayerControl &pc, unsigned i, SongTime seek_time,
queued_song = nullptr; 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); UpdateQueuedSong(pc, queued_song);
// TODO: fix error code
error.Set(playlist_domain, int(PlaylistResult::NOT_PLAYING),
"Decoder failed to seek");
return false; return false;
} }