Fixing ALSA underrun death spiral and PulseAudio buffer clamping#239
Draft
f1nalspace wants to merge 1 commit into
Draft
Fixing ALSA underrun death spiral and PulseAudio buffer clamping#239f1nalspace wants to merge 1 commit into
f1nalspace wants to merge 1 commit into
Conversation
ALSA: - After snd_pcm_set_params, override sw_params to set start_threshold to period_size instead of buffer_size. The default causes ~200ms of silence after every underrun recovery, during which PipeWire fires again and triggers another underrun — a death spiral. - Set silence_size=buffer_size so ALSA auto-fills silence during brief packet gaps, preventing XRUN before snd_pcm_writei can be called. - Add snd_pcm_drop() before snd_pcm_close() to prevent hang on close. - Use continue instead of return 0 after snd_pcm_recover so the current packet is retried rather than dropped. PulseAudio: - On format change, recalculate maxlength with the updated sample spec before recalculating tlength. Previously maxlength was set at init with the 44100 S16LE placeholder and never updated; after switching to 48kHz S32LE, tlength > maxlength, so PA silently clamped the effective buffer to ~46ms instead of the requested latency — causing the same underrun spiral.
Author
|
The problem was gone for a while, but now even with all those fixes, the noises are back - especially when i play a video on my host and install stuff in the VM that plays system sounds. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issues
Bugfixes
ALSA:
PulseAudio: