RustAudio / rodio

Rust audio playback library
Apache License 2.0
1.79k stars 232 forks source link

changing speed can cause track_position to become inaccurate #639

Open dvdsk opened 4 days ago

dvdsk commented 4 days ago

Speed should only apply changes at frame boundaries since track_position uses those to add up the currently played duration OR track_position should update its internal counter every sample.

ugochukwu-850 commented 2 days ago

This isn't clear .it seems interesting and I may want to go with it .But I don't understand what you mean yet.

dvdsk commented 1 hour ago

Speed works by changing the sample-rate. The sample rate normally only changes at frame boundaries. Track position assumes it never changes except when a new frame starts (see: https://github.com/RustAudio/rodio/blob/489e184a58c3655e7806318d2a8a7248d5055e67/src/source/position.rs#L103).

We should make it so that speed only changes the sample-rate at frame boundaries and limit the latency this causes by letting speed put an upper bound on frame boundary length.