-
Notifications
You must be signed in to change notification settings - Fork 468
alsa: update to alsa-rs 0.11 and fix device access issues #1085
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
Merged
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
b17af5d to
d2feb3c
Compare
d2feb3c to
f9ba5f6
Compare
* add Debug derives * improve error handling
Remove handle caching introduced in #506. The caching held devices open during enumeration, which prevented querying both input and output configs on duplex devices (EBUSY errors) and blocked other applications from accessing the devices. For the rare hardware where rapid open/close is problematic (like some NVIDIA HDMI cards), applications can now implement retry logic using the new DeviceBusy error variant, which separates retriable errors (EBUSY, EAGAIN) from permanent failures (ENOENT, EPERM, etc). Fixes: - #615 - #634
When the last Host is dropped, free the global ALSA config cache via alsa::config::update_free_global. This reduces Valgrind errors.
* Initialize global ALSA config on first context creation and free it when the last context is dropped using ALSA_CONTEXT_COUNT. * Re-add Device::default and use it for Host default devices.
3fab477 to
98ad346
Compare
Member
Author
|
Merging this to give it greater testing exposure. Targeted for v0.18. |
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.
This PR updates
alsa-rsto 0.11 and fixes several related issues around device enumeration, duplex device queries, and ALSA'sstderrspam during enumeration. This also includes some quality-of-life improvements likeDebugderives and better error handling.Reverts device handle caching
Previously, we cached device handles to avoid opening them repeatedly (#506). This seemed efficient, and fixed drivers that have issues with rapidly closing and opening, but it caused two real problems:
EBUSYbecause we already had it openI've reverted the caching: devices are now opened fresh for each operation. For broken drivers where rapid open/close causes issues (like some NVIDIA HDMI cards), applications can use the new
DeviceBusyerror variant to implement retry logic.Fixes:
Suppresses ALSA's
stderrspamALSA has the habit of printing error messages directly to
stderrduring normal device enumeration. Users were understandably confused by this. Theenumerate.rsexample now shows how to use the newalsa::Output::local_error_handler()to suppress these messages during enumeration.Fixes:
Manages ALSA's global configuration
ALSA maintains a process-global configuration cache that we were never properly initializing or cleaning up. This led to memory leaks that showed up in Valgrind - somewhat false positives, but still.
Now we call
alsa::config::update()when creating the firstHost, andalsa::config::update_free_global()when dropping the last one, after the lastDeviceandStreamare dropped as well. The former reduces Valgrind reports, the latter correctly throws an error when ALSA is configured incorrectly.Handling of retriable errors with
DeviceBusyI've added a new
DeviceBusyerror variant to several error types. This lets applications distinguish between retriable errors (likeEBUSYorEAGAIN) and permanent failures (likeENOENTorEPERM). This allows users to implement smart retry logic when it makes sense, and counter the rapid open/close issues described above.DebugimplementationsI've added
Debugderives toHost,Device,Stream, and internal types.Breaking changes
This will require a semver minor update to v0.18:
MSRV has been updated to 1.78 globally, and to 1.82 for ALSA specifically.
The new
DeviceBusyerror variant is technically breaking because the error enums weren't marked as#[non_exhaustive]. Users with match statements that don't have a catch-all pattern will get compilation errors.