DecoderControl: use std::chrono::duration for Seek()
This commit is contained in:
parent
58e6f660f3
commit
ba6ba7d4be
@ -567,7 +567,7 @@ Player::SeekDecoder()
|
|||||||
if (where < 0.0)
|
if (where < 0.0)
|
||||||
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 */
|
/* decoder failure */
|
||||||
player_command_finished(pc);
|
player_command_finished(pc);
|
||||||
return false;
|
return false;
|
||||||
|
@ -196,7 +196,7 @@ decoder_command_finished(Decoder &decoder)
|
|||||||
|
|
||||||
dc.pipe->Clear(*dc.buffer);
|
dc.pipe->Clear(*dc.buffer);
|
||||||
|
|
||||||
decoder.timestamp = dc.seek_where;
|
decoder.timestamp = dc.seek_time.ToDoubleS();
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.command = DecoderCommand::NONE;
|
dc.command = DecoderCommand::NONE;
|
||||||
@ -218,7 +218,7 @@ decoder_seek_time(Decoder &decoder)
|
|||||||
|
|
||||||
decoder.seeking = true;
|
decoder.seeking = true;
|
||||||
|
|
||||||
return SongTime::FromS(dc.seek_where);
|
return dc.seek_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
@ -236,7 +236,7 @@ decoder_seek_where_frame(Decoder &decoder)
|
|||||||
|
|
||||||
decoder.seeking = true;
|
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)
|
void decoder_seek_error(Decoder & decoder)
|
||||||
|
@ -105,16 +105,15 @@ DecoderControl::Stop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DecoderControl::Seek(double where)
|
DecoderControl::Seek(SongTime t)
|
||||||
{
|
{
|
||||||
assert(state != DecoderState::START);
|
assert(state != DecoderState::START);
|
||||||
assert(where >= 0.0);
|
|
||||||
|
|
||||||
if (state == DecoderState::STOP ||
|
if (state == DecoderState::STOP ||
|
||||||
state == DecoderState::ERROR || !seekable)
|
state == DecoderState::ERROR || !seekable)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
seek_where = where;
|
seek_time = t;
|
||||||
seek_error = false;
|
seek_error = false;
|
||||||
LockSynchronousCommand(DecoderCommand::SEEK);
|
LockSynchronousCommand(DecoderCommand::SEEK);
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "thread/Mutex.hxx"
|
#include "thread/Mutex.hxx"
|
||||||
#include "thread/Cond.hxx"
|
#include "thread/Cond.hxx"
|
||||||
#include "thread/Thread.hxx"
|
#include "thread/Thread.hxx"
|
||||||
|
#include "Chrono.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -107,7 +108,7 @@ struct DecoderControl {
|
|||||||
|
|
||||||
bool seek_error;
|
bool seek_error;
|
||||||
bool seekable;
|
bool seekable;
|
||||||
double seek_where;
|
SongTime seek_time;
|
||||||
|
|
||||||
/** the format of the song file */
|
/** the format of the song file */
|
||||||
AudioFormat in_audio_format;
|
AudioFormat in_audio_format;
|
||||||
@ -365,7 +366,7 @@ public:
|
|||||||
|
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
bool Seek(double where);
|
bool Seek(SongTime t);
|
||||||
|
|
||||||
void Quit();
|
void Quit();
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ struct Decoder {
|
|||||||
bool initial_seek_running;
|
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
|
* decoder_command_finished(). It is used to clean up after
|
||||||
* seeking.
|
* seeking.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user