rodio icon indicating copy to clipboard operation
rodio copied to clipboard

Sink controls redesign

Open PetrGlad opened this issue 4 months ago • 3 comments

A follow up on https://github.com/RustAudio/rodio/issues/619#issuecomment-2372360582 Current implementation of Sink unconditionally includes several audio controls like pause, volume, speed (see src/sink.rs). There are several things that can be improved over current implementation.

Users may not need all for these at once and prefer to have only necessary conversions. It is possible to make the controls composable so users can add only necessary parts and adjust audio parameters for each input separately.

Current implementation of controls (like volume control, see here ) only accepts fixed values. Sink allows to control these parameters dynamically, which is implemented with a callback that is invoked periodically. The callback applies values requested by user to the actual control. Currently this happens at about 5ms intervals.

It is possible to apply the parameters directly by using atomic values. This should reduce reaction time and simplify the 'Sink' implementation (see callback setup in src/source.rs). In case atomics turn out to be expensive on some architectures, it is still possible to simplify Sink implementation by allowing each audio converter to control its own parameters. In that case each converter will have to have its own periodic_callback.

Should be included into #619.

PetrGlad avatar Sep 30 '24 22:09 PetrGlad