Fix wrong total duration cause by divided by zero

This commit is contained in:
Methapon2001 2024-11-24 20:41:50 +07:00
parent bc8d1c7e05
commit 77896cc498
No known key found for this signature in database
GPG key ID: 849924FEF46BD132

View file

@ -170,8 +170,9 @@ impl Source for SymphoniaDecoder {
#[inline]
fn total_duration(&self) -> Option<Duration> {
self.total_duration
.map(|Time { seconds, frac }| Duration::new(seconds, (1f64 / frac) as u32))
self.total_duration.map(|Time { seconds, frac }| {
Duration::new(seconds, if frac > 0.0 { (1f64 / frac) as u32 } else { 0 })
})
}
fn try_seek(&mut self, pos: Duration) -> Result<(), source::SeekError> {