diff options
author | Max Kellermann <max@musicpd.org> | 2018-09-22 19:06:53 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-09-22 19:37:45 +0200 |
commit | 84de88841be5ca0846eed380b11ad7cf8587754a (patch) | |
tree | 153a475d1358a0ebff4e187efa023bca7e0508ec /src/player | |
parent | 224400074c61f667fb6d0d89d7170a4d04ba39b4 (diff) |
player/CrossFade: use AudioFormat::SizeToTime() instead of GetTimeToSize()
Diffstat (limited to 'src/player')
-rw-r--r-- | src/player/CrossFade.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/player/CrossFade.cxx b/src/player/CrossFade.cxx index b7c5787c4..aafd137e7 100644 --- a/src/player/CrossFade.cxx +++ b/src/player/CrossFade.cxx @@ -97,7 +97,6 @@ CrossFadeSettings::Calculate(SignedSongTime total_time, unsigned max_chunks) const noexcept { unsigned int chunks = 0; - float chunks_f; if (total_time.IsNegative() || duration <= FloatDuration::zero() || @@ -109,11 +108,12 @@ CrossFadeSettings::Calculate(SignedSongTime total_time, assert(duration > FloatDuration::zero()); assert(af.IsValid()); - chunks_f = (float)af.GetTimeToSize() / (float)sizeof(MusicChunk::data); + const auto chunk_duration = + af.SizeToTime<FloatDuration>(sizeof(MusicChunk::data)); if (mixramp_delay <= FloatDuration::zero() || !mixramp_start || !mixramp_prev_end) { - chunks = std::lround(chunks_f * duration.count()); + chunks = std::lround(duration / chunk_duration); } else { /* Calculate mixramp overlap. */ const auto mixramp_overlap_current = @@ -128,7 +128,8 @@ CrossFadeSettings::Calculate(SignedSongTime total_time, if (mixramp_overlap_current >= FloatDuration::zero() && mixramp_overlap_prev >= FloatDuration::zero() && mixramp_delay <= mixramp_overlap) { - chunks = (chunks_f * (mixramp_overlap - mixramp_delay).count()); + chunks = lround((mixramp_overlap - mixramp_delay) + / chunk_duration); FormatDebug(cross_fade_domain, "will overlap %d chunks, %fs", chunks, (mixramp_overlap - mixramp_delay).count()); |