diff options
author | Max Kellermann <max@musicpd.org> | 2018-09-23 15:14:36 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-09-23 15:15:53 +0200 |
commit | dcac32a6c491d7b24d43695c92dfdbb1a7945b3f (patch) | |
tree | 42cca0aa58343b0ad3503861c0c1fcc96705e9f3 | |
parent | 5286477f739238917c2e5ed81dd44f28be449f3e (diff) |
AudioFormat: add implicit cast to `duration::rep`
Fixes integer truncation bugs (closes #359).
-rw-r--r-- | src/AudioFormat.hxx | 3 |
1 files changed, 2 insertions, 1 deletions
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<typename D> 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<typename D> |