Seeking SamplesBuffer to position 0 panics
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- rust
- Domain
- audio-video-rtc
Research direction
The panic is in src/buffer.rs around line 116, inside the seek path of SamplesBuffer, where new_pos - curr_channel underflows when the target position is 0. Start by reading how try_seek computes new_pos and curr_channel, then reproduce with the snippet from the issue. Done means seeking to Duration::from_secs(0) no longer panics and lands on the first sample of the correct channel, with a test covering that case.
Written by the indexing model from the issue text.
Description
When seeking rodio::buffer::SamplesBuffer to Duration::from_secs(0), a panic occurs:
use rodio::nz;
use rodio::buffer::SamplesBuffer;
use std::time::Duration;
let mut buffer = SamplesBuffer::new(nz!(2), nz!(44100), vec![0.0, 0.0, 0.0, 0.0, 0.0, 0.0]);
buffer.next();
buffer.try_seek(Duration::from_secs(0));
Error message:
[windows] thread 'main' (23364) panicked at C:\Users\User\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rodio-0.22.2\src\buffer.rs:116:23:
[windows] attempt to subtract with overflow
The line where it happens:
// make sure the next sample is for the right channel
let new_pos = new_pos.next_multiple_of(self.channels().get() as usize);
let new_pos = new_pos - curr_channel;
It looks like curr_channel is being subtracted from new_pos, which in this case is equal to 0, causing an underflow.
- Dominant language
- Rust
- Stars
- 2.5k
- Forks
- 338
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RustAudio/rodio
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 73/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 67/100
-
Difficulty 4/5 3-5 days Newbie friendliness 46/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Choochmeque/tauri-plugin-webdriver#134 ·
Maintainers usually reply within 17 days
-
bug rust SDK & CLI & REST API
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
boxlite-ai/boxlite#3292 ·
Maintainers usually reply within 1 day
-
Android bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anefzaoui/misterdownloadmanager#2516 ·
Maintainers usually reply within 1 day
-
editor ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
state:triage tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 89/100
agent8-cash/ethpayserver#731 ·
Maintainers usually reply within 1 day