From dcac32a6c491d7b24d43695c92dfdbb1a7945b3f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 23 Sep 2018 15:14:36 +0200 Subject: [PATCH] AudioFormat: add implicit cast to `duration::rep` Fixes integer truncation bugs (closes #359). --- src/AudioFormat.hxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AudioFormat.hxx b/src/AudioFormat.hxx index dc2651daf..9571be652 100644 --- a/src/AudioFormat.hxx +++ b/src/AudioFormat.hxx @@ -162,8 +162,9 @@ struct AudioFormat { template constexpr D FramesToTime(std::uintmax_t size) const noexcept { + using Rep = typename D::rep; using Period = typename D::period; - return D(((size / Period::num) * Period::den) / sample_rate); + return D(((Rep(1) * size / Period::num) * Period::den) / sample_rate); } template