RustAudio / rodio

Rust audio playback library
Apache License 2.0
1.74k stars 228 forks source link

Playback stuttering #590

Open vyfor opened 3 months ago

vyfor commented 3 months ago

Hello, I'm facing noticeable audio stutters whenever I switch between applications (e.g. by Alt+Tabbing). When the same issue occurred in cpal, I simply set the buffer size to be a Fixed(4096) and that fixed the problem. However, I'm not quite sure if I can do the same in rodio. Here's how I tried to do it:

let default_config = device.default_output_config()?;
let config = SupportedStreamConfig::new(
    default_config.channels(),
    default_config.sample_rate(),
    SupportedBufferSize::Range {
        min: BUFFER_SIZE,
        max: BUFFER_SIZE,
    },
    default_config.sample_format(),
);
let (_, _) = OutputStream::try_from_device_config(&device, config)?;

But no matter how low or high I set the BUFFER_SIZE, I still experience the stutters. Running on Windows 10.

vyfor commented 3 months ago

512 seems to fix the issue.

dvdsk commented 3 months ago

512 seems to fix the issue.

good to know! We might have to change the default then. If we do that now audio latency will increase (cant imagine 4096 is a problem for anyone) but to be sure I wanna wait till after applying #512. And I'am waiting with #512 till I have time to work through some other breaking changes so we can bundle them in one release and add a migration guide to that.

dvdsk commented 2 months ago

Is your system under high cpu load when it stutters?

vyfor commented 2 months ago

Is your system under high cpu load when it stutters?

As far as I tested, I haven't experienced such issues.