mirror of
https://github.com/RustAudio/rodio
synced 2024-12-13 13:42:34 +00:00
Check if the frame length is zero in SkipDuration. (#388)
If the source we are skipping runs out of data, it will return Some(0) as the frame length. Before, this would cause an infinite loop because we would skip zero samples forever. This commit fixes it by checking explicitly if the frame length is zero and bailing out if it is.
This commit is contained in:
parent
ba78af2070
commit
2e08a7efa6
1 changed files with 6 additions and 0 deletions
|
@ -33,6 +33,12 @@ where
|
||||||
// .unwrap() safety: if `current_frame_len()` is None, the body of the `if` statement
|
// .unwrap() safety: if `current_frame_len()` is None, the body of the `if` statement
|
||||||
// above returns before we get here.
|
// above returns before we get here.
|
||||||
let frame_len: usize = input.current_frame_len().unwrap();
|
let frame_len: usize = input.current_frame_len().unwrap();
|
||||||
|
// If frame_len is zero, then there is no more data to skip. Instead
|
||||||
|
// just bail out.
|
||||||
|
if frame_len == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let ns_per_sample: u128 =
|
let ns_per_sample: u128 =
|
||||||
NS_PER_SECOND / input.sample_rate() as u128 / input.channels() as u128;
|
NS_PER_SECOND / input.sample_rate() as u128 / input.channels() as u128;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue