AudioFormat: add implicit cast to `duration::rep`

Fixes integer truncation bugs (closes #359).
This commit is contained in:
Max Kellermann 2018-09-23 15:14:36 +02:00
parent 5286477f73
commit dcac32a6c4
1 changed files with 2 additions and 1 deletions

View File

@ -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>