aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-28 13:04:45 +0200
committerMax Kellermann <max@duempel.org>2014-08-28 13:08:44 +0200
commitf02998b106a73281356d69cc7b19d069aea8cf0d (patch)
treee6a574eb9c6cf1fbe91bb92ce6261ec863b77737 /src
parent127fe6ecf001a7bfb7f9a1d704d22c5a866896a5 (diff)
downloadmpd-f02998b106a73281356d69cc7b19d069aea8cf0d.tar.gz
mpd-f02998b106a73281356d69cc7b19d069aea8cf0d.tar.xz
mpd-f02998b106a73281356d69cc7b19d069aea8cf0d.zip
DecoderControl: use std::chrono::duration for start_ms and end_ms
Diffstat (limited to 'src')
-rw-r--r--src/PlayerThread.cxx2
-rw-r--r--src/decoder/DecoderAPI.cxx20
-rw-r--r--src/decoder/DecoderControl.cxx6
-rw-r--r--src/decoder/DecoderControl.hxx19
-rw-r--r--src/decoder/DecoderThread.cxx2
5 files changed, 19 insertions, 30 deletions
diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx
index e527a80ba..37edb0a20 100644
--- a/src/PlayerThread.cxx
+++ b/src/PlayerThread.cxx
@@ -296,7 +296,7 @@ Player::StartDecoder(MusicPipe &_pipe)
start_time += pc.seek_time;
dc.Start(new DetachedSong(*pc.next_song),
- start_time.ToMS(), pc.next_song->GetEndTime().ToMS(),
+ start_time, pc.next_song->GetEndTime(),
buffer, _pipe);
}
diff --git a/src/decoder/DecoderAPI.cxx b/src/decoder/DecoderAPI.cxx
index 83acb8a89..f34894b6a 100644
--- a/src/decoder/DecoderAPI.cxx
+++ b/src/decoder/DecoderAPI.cxx
@@ -179,7 +179,7 @@ decoder_command_finished(Decoder &decoder)
assert(dc.pipe->IsEmpty());
decoder.initial_seek_running = false;
- decoder.timestamp = dc.start_ms / 1000.;
+ decoder.timestamp = dc.start_time.ToDoubleS();
dc.Unlock();
return;
}
@@ -212,7 +212,7 @@ decoder_seek_time(Decoder &decoder)
assert(dc.pipe != nullptr);
if (decoder.initial_seek_running)
- return SongTime(dc.start_ms);
+ return dc.start_time;
assert(dc.command == DecoderCommand::SEEK);
@@ -226,17 +226,7 @@ decoder_seek_where_frame(Decoder &decoder)
{
const DecoderControl &dc = decoder.dc;
- assert(dc.pipe != nullptr);
-
- if (decoder.initial_seek_running)
- return uint64_t(dc.start_ms) * dc.in_audio_format.sample_rate
- / 1000;
-
- assert(dc.command == DecoderCommand::SEEK);
-
- decoder.seeking = true;
-
- return dc.seek_time.ToScale<uint64_t>(dc.in_audio_format.sample_rate);
+ return decoder_seek_time(decoder).ToScale<uint64_t>(dc.in_audio_format.sample_rate);
}
void decoder_seek_error(Decoder & decoder)
@@ -553,8 +543,8 @@ decoder_data(Decoder &decoder,
decoder.timestamp += (double)nbytes /
dc.out_audio_format.GetTimeToSize();
- if (dc.end_ms > 0 &&
- decoder.timestamp >= dc.end_ms / 1000.0)
+ if (dc.end_time.IsPositive() &&
+ decoder.timestamp >= dc.end_time.ToDoubleS())
/* the end of this range has been reached:
stop decoding */
return DecoderCommand::STOP;
diff --git a/src/decoder/DecoderControl.cxx b/src/decoder/DecoderControl.cxx
index c4892a659..c30da6214 100644
--- a/src/decoder/DecoderControl.cxx
+++ b/src/decoder/DecoderControl.cxx
@@ -70,7 +70,7 @@ DecoderControl::IsCurrentSong(const DetachedSong &_song) const
void
DecoderControl::Start(DetachedSong *_song,
- unsigned _start_ms, unsigned _end_ms,
+ SongTime _start_time, SongTime _end_time,
MusicBuffer &_buffer, MusicPipe &_pipe)
{
assert(_song != nullptr);
@@ -78,8 +78,8 @@ DecoderControl::Start(DetachedSong *_song,
delete song;
song = _song;
- start_ms = _start_ms;
- end_ms = _end_ms;
+ start_time = _start_time;
+ end_time = _end_time;
buffer = &_buffer;
pipe = &_pipe;
diff --git a/src/decoder/DecoderControl.hxx b/src/decoder/DecoderControl.hxx
index 7a72d1408..d1a55e7b3 100644
--- a/src/decoder/DecoderControl.hxx
+++ b/src/decoder/DecoderControl.hxx
@@ -127,21 +127,20 @@ struct DecoderControl {
DetachedSong *song;
/**
- * The initial seek position (in milliseconds), e.g. to the
- * start of a sub-track described by a CUE file.
+ * The initial seek position, e.g. to the start of a sub-track
+ * described by a CUE file.
*
* This attribute is set by Start().
*/
- unsigned start_ms;
+ SongTime start_time;
/**
- * The decoder will stop when it reaches this position (in
- * milliseconds). 0 means don't stop before the end of the
- * file.
+ * The decoder will stop when it reaches this position. 0
+ * means don't stop before the end of the file.
*
* This attribute is set by Start().
*/
- unsigned end_ms;
+ SongTime end_time;
float total_time;
@@ -356,12 +355,12 @@ public:
*
* @param song the song to be decoded; the given instance will be
* owned and freed by the decoder
- * @param start_ms see #DecoderControl
- * @param end_ms see #DecoderControl
+ * @param start_time see #DecoderControl
+ * @param end_time see #DecoderControl
* @param pipe the pipe which receives the decoded chunks (owned by
* the caller)
*/
- void Start(DetachedSong *song, unsigned start_ms, unsigned end_ms,
+ void Start(DetachedSong *song, SongTime start_time, SongTime end_time,
MusicBuffer &buffer, MusicPipe &pipe);
void Stop();
diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx
index 06735de83..3f4f7c42e 100644
--- a/src/decoder/DecoderThread.cxx
+++ b/src/decoder/DecoderThread.cxx
@@ -360,7 +360,7 @@ static void
decoder_run_song(DecoderControl &dc,
const DetachedSong &song, const char *uri, Path path_fs)
{
- Decoder decoder(dc, dc.start_ms > 0,
+ Decoder decoder(dc, dc.start_time.IsPositive(),
new Tag(song.GetTag()));
int ret;