-
Notifications
You must be signed in to change notification settings - Fork 424
ALSA: fix buffer size / period size configuration #917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
9879b3c
to
62324d5
Compare
With ALSA, the buffer size is `nperiod * period_size`. We want 2 periods ideally. The default is now set to 1024 samples which is a reasonable default, yet still too large for real-time audio. The default value now uses the same code path as custom values. Fixes RustAudio#913
62324d5
to
8d86b11
Compare
It is now a month that this PR is opened. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no rights to cpal, so this is symbolic, but having implemented a ALSA backend for my interflow
crate, those changes are small enough that there's no worry to merge this.
@est31 Hi, any chance this PR gets merged or closed with a comment? |
Hey, I tested this PR and I don't think it works as expected because the PR is not explicitly setting the buffer size at all and I received unexpectedly huge buffers (~1MB) whereas with fixed buffer setting I'm expecting to get a buffer of that exact size. Full disclosure: we are using alsa's pipewire device and we were struggling with getting buffers of the right size. Because of the former |
Buffer size isn't relevant. |
Can you elaborate? Are you perhaps suggesting that the buffer contains a period size worth of actual samples and the rest is just junk that can be ignored? We use a webrtc processor for AEC and it seems to require fixed sized buffers. We tried doing buffering ourselves on top of non-fixed buffers given to us by cpal but that introduced timing jitter that prevented AEC to work correctly. With portaudio we get fixed size buffers and AEC works correctly. To be sure, I'm a beginner when it comes to audio, so it's very much possible I misunderstand some core concepts but it sure does appear that buffer sizes are relevant at least in some cases. |
An alsa buffer, is a continuous memory used as a circular buffer. What is important is the period size (in frames) that defines your latency. So there's nothing wrong with a bigger buffer, it just takes more memory. For alsa, period size and num periods defines your latency and working context. |
Thank you @abique, that makes a lot of sense! It would be nice to also improve the |
With ALSA, the buffer size is
nperiod * period_size
. We want 2 periods ideally.The default is now set to 1024 samples which is a reasonable default, yet still too large for real-time audio.
Also the default value uses the same code path as custom values.
Fixes #913
Depends on #915 for successful compilation.
Replaces #914