Skip to content

limit-buffersize#856

Merged
yara-blue merged 2 commits intomasterfrom
default-buffer-size
Feb 28, 2026
Merged

limit-buffersize#856
yara-blue merged 2 commits intomasterfrom
default-buffer-size

Conversation

@yara-blue
Copy link
Member

fixes #853

huge cpal default buffer sizes (due to weirdly set up systems) are a footgun.

This makes from_device replace BufferSize::Default with a fixed 4096 samples. This affects from_default_device & open_default_sink.

@roderickvd
Copy link
Member

roderickvd commented Feb 27, 2026

I suggest to use the sample rate and channel count to calculate an audio latency of ~100 ms. Almost everywhere there's a double-buffering scheme, so that means that one buffer should represent ~50 ms.

For bonus points the buffer sizes are rounded to a safe and performant power of two.

@yara-blue
Copy link
Member Author

I suggest to use the sample rate to calculate an audio latency of ~100 ms. Almost everywhere there's a double-buffering scheme, so that means that one buffer should represent ~50 ms.

For bonus points the buffer sizes are rounded to a safe and performant power of two.

yes that makes way more sense :) I'll do that and merge. Shall we put out a new patch release after that?

@roderickvd
Copy link
Member

Yeah.

Edit: sample rate and channel count

@yara-blue
Copy link
Member Author

overhauled the experimental new device opening API (working title: speakers), it now does this nicely. The change to the stable API is just 17 lines.

@yara-blue yara-blue marked this pull request as draft February 27, 2026 17:46
@yara-blue
Copy link
Member Author

opportunity for a really nice refactor appeared. I'm looking into that

@yara-blue yara-blue force-pushed the default-buffer-size branch 2 times, most recently from 9359af4 to 866d6d5 Compare February 28, 2026 16:35
@yara-blue yara-blue marked this pull request as ready for review February 28, 2026 17:56
@yara-blue
Copy link
Member Author

Merging this so I can easily see what it does to #853 feel free to discuss/review further here if you want too

@yara-blue yara-blue merged commit f41bc47 into master Feb 28, 2026
3 checks passed
@roderickvd
Copy link
Member

We probably should document that Rodio configures a default buffer with a latency near 100 ms:

  • regardless of system defaults
  • unless a buffer size is specified manually

Before cpal changed this behavior, users found it surprising that their system settings were ignored.

@yara-blue
Copy link
Member Author

We probably should document that Rodio configures a default buffer with a latency near 100 ms:

* regardless of system defaults

* unless a buffer size is specified manually

Before cpal changed this behavior, users found it surprising that their system settings were ignored.

done in 1cd15f8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_pos much further ahead than actual playback position

2 participants