Repository navigation
wasapi: release MMCSS registration when the worker exits - #1406
Closed
derekmwright wants to merge 2 commits into
Closed
derekmwright wants to merge 2 commits into
derekmwright wants to merge 2 commits into
Conversation
Collaborator
|
Sry, but this is very over-engineered and copypasty. |
Contributor
Author
|
I can pare down a much smaller fix for this if you'd like me to resubmit. The leak is still there and should be fixed. The agent was using my own standards around testing and didn't fully respect this repos style/submission guidelines. |
Collaborator
|
Feel free to do so. Just please review the code yourself before submitting it. |
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.
The WASAPI worker promotes itself with
audio_thread_priority::promote_current_thread_to_real_time, butboost_current_thread_prioritydiscards the returnedRtPriorityHandle(Ok(_) => Ok(())). The handle has noDrop, soAvRevertMmThreadCharacteristicsis never called for a stream's worker.This change keeps the handle in a guard that lives on the worker for the whole run loop and reverts it on that same thread when the worker exits: normal stop, run-loop and device errors, early returns, and unwinding from a panic in a callback. A failed registration creates no guard, and the existing
SetThreadPriorityfallback is unchanged. A failed revert is reported through the stream's error callback on a best-effort basis: not while panicking, and not if the callback's mutex is contended.Input and output workers both go through one
priority::run(acquire, body)prologue, so the guard's lifetime is covered by unit tests rather than only by device runs.Testing:
cargo test --libwith and without therealtimefeature on Windows: 18 passed. Clippy matches the base in both feature modes.Not covered: ALSA and PipeWire call the same helper and appear to have the same issue, but their ownership model is different (rtkit), so they are left for a separate change.