mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2025-03-04 14:57:17 +00:00
wav: Fix issue #174 and add regression test
This commit is contained in:
parent
abbc484164
commit
e3fa808d96
3 changed files with 23 additions and 8 deletions
|
@ -182,15 +182,18 @@ pub(super) fn read_properties(
|
|||
}
|
||||
} else if stream_len > 0 && bytes_per_second > 0 {
|
||||
let length = (u64::from(stream_len) * 1000) / u64::from(bytes_per_second);
|
||||
if length == 0 {
|
||||
(Duration::ZERO, 0, 0)
|
||||
} else {
|
||||
let overall_bitrate = ((file_length * 8) / length) as u32;
|
||||
let audio_bitrate = (bytes_per_second * 8) / 1000;
|
||||
|
||||
let overall_bitrate = ((file_length * 8) / length) as u32;
|
||||
let audio_bitrate = (bytes_per_second * 8) / 1000;
|
||||
|
||||
(
|
||||
Duration::from_millis(length),
|
||||
overall_bitrate,
|
||||
audio_bitrate,
|
||||
)
|
||||
(
|
||||
Duration::from_millis(length),
|
||||
overall_bitrate,
|
||||
audio_bitrate,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
(Duration::ZERO, 0, 0)
|
||||
};
|
||||
|
|
Binary file not shown.
|
@ -70,3 +70,15 @@ fn remove_riff_info() {
|
|||
TagType::RIFFInfo
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_174_divide_by_zero() {
|
||||
let file = Probe::open(
|
||||
"tests/files/assets/issue_174_waveformatextensible-ieeefloat-44100Hz-mono95060.wav",
|
||||
)
|
||||
.unwrap()
|
||||
.read()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(file.file_type(), FileType::WAV);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue