Commit ba6ba7d4 authored by Max Kellermann's avatar Max Kellermann

DecoderControl: use std::chrono::duration for Seek()

parent 58e6f660
......@@ -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;
......
......@@ -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)
......
......@@ -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);
......
......@@ -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();
......
......@@ -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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment