-
Notifications
You must be signed in to change notification settings - Fork 391
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
proposal: allow setting thread priority for stream threads #939
Comments
Maybe CPAL should always set the audio thread to realtime via something like https://github.com/mozilla/audio_thread_priority, or make this at least be an option. |
This should certainly be the default when cpal spawns a thread itself. A config option should not be added unless there's a clear use case for one. |
Looks like this is already done on WASAPI, but not on other platforms? I'm honestly not sure. cpal/src/host/wasapi/stream.rs Lines 325 to 334 in 4a8c9b8
|
I am using ALSA host, which seems to just spawn a thread Lines 942 to 960 in 4a8c9b8
|
One issue I discovered is that at least in my Ubuntu installation, user processes do not have permission to set both
(1 is |
When my CPU is under high load, the sound thread does not get enough compute time, which leads to buffer underruns and clicking.
Setting high priority on sound producing threads allows producing uninterrupted sound even with a high load, but this is not straightforward with the current API.
Do we want this to be configurable?
Maybe. There might be some environments where there should be limited number of realtime threads and stuttering sound is less of a priority.
If we do want to configure the priority, what is the API?
I see two paths:
build_input_stream
build_input_stream_with_priority
Thank you for maintaining this library!
The text was updated successfully, but these errors were encountered: