-
Notifications
You must be signed in to change notification settings - Fork 450
fix(alsa): ALSA template errors during enumeration #1035
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
Open
roderickvd
wants to merge
13
commits into
master
Choose a base branch
from
fix/pointless-device-opening
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−144
Conversation
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
Avoid setting period count when BufferSize::Default is used, allowing PipeWire-ALSA to select optimal buffer and period sizes. This prevents excessively large periods and high latency on PipeWire-ALSA devices.
Member
Author
|
Note to self: |
Set buffer_size_near before period_size_near for Fixed buffer sizes to constrain total latency and avoid extremely large allocations (eg. PipeWire-ALSA creating ~1M-frame buffers). Then set period_size to keep double-buffering semantics. Adjust avail_min by direction: for playback wake when level drops to one period (buffer - period); for capture wake when one period is available (period) to prevent excessive capture latency.
Revert to v0.16 behavior: always terminate stream without attempting state-based drain or wait. Remove buffer-duration calculation and snd_pcm_wait usage to avoid delays during drop.
Query the device's period size and set buffer_size to 2 * period for BufferSize::Default. This prevents excessive memory allocation (e.g. PipeWire-ALSA) while respecting the device's period preference.
This should always align with the two-period double-buffering strategy that we use anyway.
- Introduce init_hw_params and a TryFrom<SampleFormat> implementation to centralize format and hw param initialization. - For BufferSize::Default, constrain both period and buffer to enforce double-buffering (2 periods), preventing pathologically large periods with PipeWire-ALSA. - Update docs to clarify ring buffer/period behaviors and add issue references.
4c7eaad to
9c8ea9a
Compare
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.
Reported on Discord:
This is due to trying to open devices that were configured as templates in ALSA. Basically this is an ALSA configuration mistake, however, there's no point to cpal trying to open them either, so that's just removed now.
Cleaned up a little while there.
This PR builds on top of #1033, so review just the last commits to see what's changed on top.