diff options
author | Max Kellermann <max@duempel.org> | 2014-08-27 18:38:41 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-27 18:48:43 +0200 |
commit | ba6ba7d4be6f43c5b6ba65a106fbf2ed40a53b45 (patch) | |
tree | b5da178e2de8694c6354794631d3bc3906368442 /src | |
parent | 58e6f660f3ff0abc77eb879814188809e9bf1995 (diff) | |
download | mpd-ba6ba7d4be6f43c5b6ba65a106fbf2ed40a53b45.tar.gz mpd-ba6ba7d4be6f43c5b6ba65a106fbf2ed40a53b45.tar.xz mpd-ba6ba7d4be6f43c5b6ba65a106fbf2ed40a53b45.zip |
DecoderControl: use std::chrono::duration for Seek()
Diffstat (limited to 'src')
-rw-r--r-- | src/PlayerThread.cxx | 2 | ||||
-rw-r--r-- | src/decoder/DecoderAPI.cxx | 6 | ||||
-rw-r--r-- | src/decoder/DecoderControl.cxx | 5 | ||||
-rw-r--r-- | src/decoder/DecoderControl.hxx | 5 | ||||
-rw-r--r-- | src/decoder/DecoderInternal.hxx | 2 |
5 files changed, 10 insertions, 10 deletions
diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx index 8a39ed348..1850a1711 100644 --- a/src/PlayerThread.cxx +++ b/src/PlayerThread.cxx @@ -567,7 +567,7 @@ Player::SeekDecoder() if (where < 0.0) where = 0.0; - if (!dc.Seek(where + start_ms / 1000.0)) { + if (!dc.Seek(SongTime::FromS(where) + SongTime::FromMS(start_ms))) { /* decoder failure */ player_command_finished(pc); return false; diff --git a/src/decoder/DecoderAPI.cxx b/src/decoder/DecoderAPI.cxx index c9bdb46e8..939434f83 100644 --- a/src/decoder/DecoderAPI.cxx +++ b/src/decoder/DecoderAPI.cxx @@ -196,7 +196,7 @@ decoder_command_finished(Decoder &decoder) dc.pipe->Clear(*dc.buffer); - decoder.timestamp = dc.seek_where; + decoder.timestamp = dc.seek_time.ToDoubleS(); } dc.command = DecoderCommand::NONE; @@ -218,7 +218,7 @@ decoder_seek_time(Decoder &decoder) decoder.seeking = true; - return SongTime::FromS(dc.seek_where); + return dc.seek_time; } uint64_t @@ -236,7 +236,7 @@ decoder_seek_where_frame(Decoder &decoder) decoder.seeking = true; - return uint64_t(dc.seek_where * dc.in_audio_format.sample_rate); + return dc.seek_time.ToScale<uint64_t>(dc.in_audio_format.sample_rate); } void decoder_seek_error(Decoder & decoder) diff --git a/src/decoder/DecoderControl.cxx b/src/decoder/DecoderControl.cxx index d78fc66c9..c4892a659 100644 --- a/src/decoder/DecoderControl.cxx +++ b/src/decoder/DecoderControl.cxx @@ -105,16 +105,15 @@ DecoderControl::Stop() } bool -DecoderControl::Seek(double where) +DecoderControl::Seek(SongTime t) { assert(state != DecoderState::START); - assert(where >= 0.0); if (state == DecoderState::STOP || state == DecoderState::ERROR || !seekable) return false; - seek_where = where; + seek_time = t; seek_error = false; LockSynchronousCommand(DecoderCommand::SEEK); diff --git a/src/decoder/DecoderControl.hxx b/src/decoder/DecoderControl.hxx index f78ce1a31..edb7ce6da 100644 --- a/src/decoder/DecoderControl.hxx +++ b/src/decoder/DecoderControl.hxx @@ -26,6 +26,7 @@ #include "thread/Mutex.hxx" #include "thread/Cond.hxx" #include "thread/Thread.hxx" +#include "Chrono.hxx" #include "util/Error.hxx" #include <assert.h> @@ -107,7 +108,7 @@ struct DecoderControl { bool seek_error; bool seekable; - double seek_where; + SongTime seek_time; /** the format of the song file */ AudioFormat in_audio_format; @@ -365,7 +366,7 @@ public: void Stop(); - bool Seek(double where); + bool Seek(SongTime t); void Quit(); diff --git a/src/decoder/DecoderInternal.hxx b/src/decoder/DecoderInternal.hxx index e6c30d071..24b665e85 100644 --- a/src/decoder/DecoderInternal.hxx +++ b/src/decoder/DecoderInternal.hxx @@ -57,7 +57,7 @@ struct Decoder { bool initial_seek_running; /** - * This flag is set by decoder_seek_where(), and checked by + * This flag is set by decoder_seek_time(), and checked by * decoder_command_finished(). It is used to clean up after * seeking. */ |