summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/decoder/Bridge.cxx16
-rw-r--r--src/decoder/Bridge.hxx4
-rw-r--r--src/decoder/Client.hxx2
-rw-r--r--src/decoder/plugins/Mpg123DecoderPlugin.cxx3
-rw-r--r--src/decoder/plugins/OpusDecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/SidplayDecoderPlugin.cxx2
-rw-r--r--src/decoder/plugins/VorbisDecoderPlugin.cxx2
-rw-r--r--src/lib/ffmpeg/Time.hxx6
-rw-r--r--test/DumpDecoderClient.cxx2
-rw-r--r--test/DumpDecoderClient.hxx2
10 files changed, 21 insertions, 20 deletions
diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx
index 06e02d24b..08a3c51d5 100644
--- a/src/decoder/Bridge.cxx
+++ b/src/decoder/Bridge.cxx
@@ -290,7 +290,7 @@ DecoderBridge::CommandFinished()
assert(dc.pipe->IsEmpty());
initial_seek_running = false;
- timestamp = dc.start_time.ToDoubleS();
+ timestamp = std::chrono::duration_cast<FloatDuration>(dc.start_time);
absolute_frame = dc.start_time.ToScale<uint64_t>(dc.in_audio_format.sample_rate);
return;
}
@@ -307,7 +307,7 @@ DecoderBridge::CommandFinished()
if (convert != nullptr)
convert->Reset();
- timestamp = dc.seek_time.ToDoubleS();
+ timestamp = std::chrono::duration_cast<FloatDuration>(dc.seek_time);
absolute_frame = dc.seek_time.ToScale<uint64_t>(dc.in_audio_format.sample_rate);
}
@@ -413,12 +413,12 @@ try {
}
void
-DecoderBridge::SubmitTimestamp(double t)
+DecoderBridge::SubmitTimestamp(FloatDuration t)
{
- assert(t >= 0);
+ assert(t.count() >= 0);
timestamp = t;
- absolute_frame = uint64_t(t * dc.in_audio_format.sample_rate);
+ absolute_frame = uint64_t(t.count() * dc.in_audio_format.sample_rate);
}
DecoderCommand
@@ -506,7 +506,7 @@ DecoderBridge::SubmitData(InputStream *is,
const auto dest =
chunk->Write(dc.out_audio_format,
- SongTime::FromS(timestamp) -
+ SongTime::Cast(timestamp) -
dc.song->GetStartTime(),
kbit_rate);
if (dest.empty()) {
@@ -532,8 +532,8 @@ DecoderBridge::SubmitData(InputStream *is,
data = (const uint8_t *)data + nbytes;
length -= nbytes;
- timestamp += (double)nbytes /
- dc.out_audio_format.GetTimeToSize();
+ timestamp += FloatDuration((double)nbytes /
+ dc.out_audio_format.GetTimeToSize());
}
absolute_frame += data_frames;
diff --git a/src/decoder/Bridge.hxx b/src/decoder/Bridge.hxx
index e19d28e27..76ce9ab3a 100644
--- a/src/decoder/Bridge.hxx
+++ b/src/decoder/Bridge.hxx
@@ -49,7 +49,7 @@ public:
/**
* The time stamp of the next data chunk, in seconds.
*/
- double timestamp = 0;
+ FloatDuration timestamp = FloatDuration::zero();
/**
* The time stamp of the next data chunk, in PCM frames.
@@ -148,7 +148,7 @@ public:
void SeekError() override;
InputStreamPtr OpenUri(const char *uri) override;
size_t Read(InputStream &is, void *buffer, size_t length) override;
- void SubmitTimestamp(double t) override;
+ void SubmitTimestamp(FloatDuration t) override;
DecoderCommand SubmitData(InputStream *is,
const void *data, size_t length,
uint16_t kbit_rate) override;
diff --git a/src/decoder/Client.hxx b/src/decoder/Client.hxx
index f8f190fda..d5209b8fe 100644
--- a/src/decoder/Client.hxx
+++ b/src/decoder/Client.hxx
@@ -115,7 +115,7 @@ public:
* use this function if it thinks that adding to the time stamp based
* on the buffer size won't work.
*/
- virtual void SubmitTimestamp(double t) = 0;
+ virtual void SubmitTimestamp(FloatDuration t) = 0;
/**
* This function is called by the decoder plugin when it has
diff --git a/src/decoder/plugins/Mpg123DecoderPlugin.cxx b/src/decoder/plugins/Mpg123DecoderPlugin.cxx
index cc019cffc..3a51f616a 100644
--- a/src/decoder/plugins/Mpg123DecoderPlugin.cxx
+++ b/src/decoder/plugins/Mpg123DecoderPlugin.cxx
@@ -264,7 +264,8 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs)
client.SeekError();
else {
client.CommandFinished();
- client.SubmitTimestamp(c / (double)audio_format.sample_rate);
+ client.SubmitTimestamp(FloatDuration(c)
+ / audio_format.sample_rate);
}
cmd = DecoderCommand::NONE;
diff --git a/src/decoder/plugins/OpusDecoderPlugin.cxx b/src/decoder/plugins/OpusDecoderPlugin.cxx
index ab6ed06f5..0404e4a40 100644
--- a/src/decoder/plugins/OpusDecoderPlugin.cxx
+++ b/src/decoder/plugins/OpusDecoderPlugin.cxx
@@ -243,7 +243,7 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
throw cmd;
if (packet.granulepos > 0)
- client.SubmitTimestamp(double(packet.granulepos)
+ client.SubmitTimestamp(FloatDuration(packet.granulepos)
/ opus_sample_rate);
}
}
diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx
index ce154399f..1d74a4d13 100644
--- a/src/decoder/plugins/SidplayDecoderPlugin.cxx
+++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx
@@ -403,7 +403,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
const size_t nbytes = result;
#endif
- client.SubmitTimestamp((double)player.time() / timebase);
+ client.SubmitTimestamp(FloatDuration(player.time()) / timebase);
cmd = client.SubmitData(nullptr, buffer, nbytes, 0);
diff --git a/src/decoder/plugins/VorbisDecoderPlugin.cxx b/src/decoder/plugins/VorbisDecoderPlugin.cxx
index 2a399ee26..9ab13dc62 100644
--- a/src/decoder/plugins/VorbisDecoderPlugin.cxx
+++ b/src/decoder/plugins/VorbisDecoderPlugin.cxx
@@ -298,7 +298,7 @@ VorbisDecoder::OnOggPacket(const ogg_packet &_packet)
#ifndef HAVE_TREMOR
if (packet.granulepos > 0)
- client.SubmitTimestamp(vorbis_granule_time(&dsp, packet.granulepos));
+ client.SubmitTimestamp(FloatDuration(vorbis_granule_time(&dsp, packet.granulepos)));
#endif
}
}
diff --git a/src/lib/ffmpeg/Time.hxx b/src/lib/ffmpeg/Time.hxx
index cba1fe4c1..4df737ec4 100644
--- a/src/lib/ffmpeg/Time.hxx
+++ b/src/lib/ffmpeg/Time.hxx
@@ -40,13 +40,13 @@ extern "C" {
* Convert a FFmpeg time stamp to a floating point value (in seconds).
*/
gcc_const
-static inline double
+static inline FloatDuration
FfmpegTimeToDouble(int64_t t, const AVRational time_base) noexcept
{
assert(t != (int64_t)AV_NOPTS_VALUE);
- return (double)av_rescale_q(t, time_base, (AVRational){1, 1024})
- / (double)1024;
+ return FloatDuration(av_rescale_q(t, time_base, (AVRational){1, 1024}))
+ / 1024;
}
/**
diff --git a/test/DumpDecoderClient.cxx b/test/DumpDecoderClient.cxx
index d6f29d192..f7156c5c3 100644
--- a/test/DumpDecoderClient.cxx
+++ b/test/DumpDecoderClient.cxx
@@ -87,7 +87,7 @@ DumpDecoderClient::Read(InputStream &is, void *buffer, size_t length)
}
void
-DumpDecoderClient::SubmitTimestamp(gcc_unused double t)
+DumpDecoderClient::SubmitTimestamp(gcc_unused FloatDuration t)
{
}
diff --git a/test/DumpDecoderClient.hxx b/test/DumpDecoderClient.hxx
index 77b5cd60c..8a40e7415 100644
--- a/test/DumpDecoderClient.hxx
+++ b/test/DumpDecoderClient.hxx
@@ -50,7 +50,7 @@ public:
void SeekError() override;
InputStreamPtr OpenUri(const char *uri) override;
size_t Read(InputStream &is, void *buffer, size_t length) override;
- void SubmitTimestamp(double t) override;
+ void SubmitTimestamp(FloatDuration t) override;
DecoderCommand SubmitData(InputStream *is,
const void *data, size_t length,
uint16_t kbit_rate) override;