aboutsummaryrefslogtreecommitdiffstats
path: root/src/PlayerThread.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-27 18:50:16 +0200
committerMax Kellermann <max@duempel.org>2014-08-27 19:07:16 +0200
commit0f2a7226fb36b3b04b1fa408882a8f0920081850 (patch)
tree009050341ed7e6335c7810a1027c00d462bae38c /src/PlayerThread.cxx
parentf8d0ebe92f9ceb4be761078395ef51a15fb0ae47 (diff)
downloadmpd-0f2a7226fb36b3b04b1fa408882a8f0920081850.tar.gz
mpd-0f2a7226fb36b3b04b1fa408882a8f0920081850.tar.xz
mpd-0f2a7226fb36b3b04b1fa408882a8f0920081850.zip
PlayerControl: use std::chrono::duration for Seek()
Diffstat (limited to 'src/PlayerThread.cxx')
-rw-r--r--src/PlayerThread.cxx19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx
index 00f8007a1..0aa8d105d 100644
--- a/src/PlayerThread.cxx
+++ b/src/PlayerThread.cxx
@@ -293,7 +293,7 @@ Player::StartDecoder(MusicPipe &_pipe)
unsigned start_ms = pc.next_song->GetStartMS();
if (pc.command == PlayerCommand::SEEK)
- start_ms += (unsigned)(pc.seek_where * 1000);
+ start_ms += pc.seek_time.ToMS();
dc.Start(new DetachedSong(*pc.next_song),
start_ms, pc.next_song->GetEndMS(),
@@ -561,19 +561,20 @@ Player::SeekDecoder()
/* send the SEEK command */
- double where = pc.seek_where;
- if (pc.total_time > 0 && where > pc.total_time)
- where = pc.total_time - 0.1;
- if (where < 0.0)
- where = 0.0;
+ SongTime where = pc.seek_time;
+ if (pc.total_time > 0) {
+ const SongTime total_time = SongTime::FromS(pc.total_time);
+ if (where > total_time)
+ where = total_time;
+ }
- if (!dc.Seek(SongTime::FromS(where) + SongTime::FromMS(start_ms))) {
+ if (!dc.Seek(where + SongTime::FromMS(start_ms))) {
/* decoder failure */
player_command_finished(pc);
return false;
}
- elapsed_time = where;
+ elapsed_time = where.ToDoubleS();
player_command_finished(pc);
@@ -923,7 +924,7 @@ Player::Run()
pc.state = PlayerState::PLAY;
if (pc.command == PlayerCommand::SEEK)
- elapsed_time = pc.seek_where;
+ elapsed_time = pc.seek_time.ToDoubleS();
pc.CommandFinished();