Skip to content

Commit 70d01da

Browse files
authored
Merge pull request #699 from IohannRabeson/fix_total_duration
Fix WavDecoder::total_duration. Note there are tests as part of #697 those are partially wrong and will break because of this being merged. We should use ffprobe to check the correct play times and put those in the test.
2 parents 8fd0337 + 8b24324 commit 70d01da

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/decoder/wav.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ where
4444
let channels = spec.channels;
4545

4646
let total_duration = {
47-
let sample_rate = sample_rate as u64;
48-
let secs = len / sample_rate;
49-
let nanos = ((len % sample_rate) * 1_000_000_000) / sample_rate;
47+
let data_rate = sample_rate as u64 * channels as u64;
48+
let secs = len / data_rate;
49+
let nanos = ((len % data_rate) * 1_000_000_000) / data_rate;
5050
Duration::new(secs, nanos as u32)
5151
};
5252

0 commit comments

Comments
 (0)