fix(audio): release the device before reopening it exclusively - #606
Draft
InstaZDLL wants to merge 2 commits into
Draft
fix(audio): release the device before reopening it exclusively#606InstaZDLL wants to merge 2 commits into
InstaZDLL wants to merge 2 commits into
Conversation
Clippy runs on the Linux slot only, on the stated grounds that its answer cannot differ by operating system. That holds for portable code and not for code behind a cfg: the Windows backend is never compiled where clippy runs, so needless_borrow sat in it from the day the shared period fill landed. The macOS backend has no job at all and is linted nowhere.
A device switch opens the new stream before tearing the old one down, so a failed open costs nothing and the stream being listened to survives. The premise is that the two streams target different endpoints. A device that has gone away breaks it: when the pinned name is no longer enumerated, pick_device falls back to the default endpoint, which can be the one the old stream already holds exclusively. Windows then refuses the open against ourselves, we drop to shared mode, and nothing says why. The rule for this already existed and both other rebuild paths consult it; the switch path did not. Three things measured on Windows 11 rather than assumed, because the comment being corrected here asserted the second one backwards. An exclusive client does block a second exclusive open of the same endpoint. A shared client blocks nothing: an exclusive Initialize succeeds while one of our own shared streams is open and running. And the block clears about 19 milliseconds after the client is dropped, which rules out a release still in flight as the explanation for a loop lasting seconds. What this does not establish is that the silence the reporter describes has the same cause as the storm of failed opens in their log. They are two distinct moments and only one symptom was reported.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
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.
Addresses the reproducible half of #604.
What the logs actually say
0x8889000AisAUDCLNT_E_DEVICE_IN_USE, and the question was who held thedevice. Three facts, measured on Windows 11 with a throwaway probe rather
than reasoned about:
Initializein exclusive mode succeeds while one of our own shared streams is open and running on the same endpoint.0x8889000A.The third one matters because it rules out the leading hypothesis. A
release still in flight cannot explain a loop that ran for twelve seconds.
The holder was still alive.
Who was holding it
set_output_deviceopens the replacement stream before releasing theold one, and says why: the two streams target different endpoints, so a
failed open costs nothing and playback survives. That premise is what a
vanished device breaks.
pick_devicefalls back to the defaultendpoint when the pinned name is no longer enumerated — which is precisely
the state after a Bluetooth headset disconnects — and that endpoint can be
the one the old exclusive stream is still holding. The open is then refused
against ourselves.
The rule for this already existed.
must_release_before_reopeningwasadded for the same class of defect on macOS, and both
force_rebuild_outputand
set_exclusive_outputconsult it. The switch path never did.A shared old stream still keeps the spawn-first order and the rollback it
buys, because the first measurement above says it is no obstacle.
A correction
The doc comment being touched here claimed Windows evicts the shared client
when the endpoint is seized. That was written from reasoning, not from a
run, and it is backwards in a way that mattered: it is exactly the sentence
that made a shared client look like the suspect. It now carries the
measurement instead.
The other commit
Clippy runs on the Linux slot only, on the stated grounds that its answer
cannot differ by operating system. True for portable code, false for code
behind a
cfg:wasapi_exclusive.rsis never compiled where clippy runs,so a
needless_borrowsat in it from the day the shared period filllanded.
coreaudio_exclusive.rshas no job at all and is linted nowhere.The lint is fixed here; whether to run clippy on the Windows slot is a
cost decision left to the maintainer, since the current arrangement is
documented as deliberate.
What this does not close
The reporter describes silence; the logs also show a storm of failed opens.
They are two distinct moments — 04:58 and 06:20 — and only one symptom was
reported. Nothing here establishes they share a cause, and #604 should stay
open until its author confirms.
The silent redirect itself is untouched: a pinned device that has vanished
still becomes the default one with only a log line to say so, and the
picker still shows the old selection. That is #597, and #604 is what it
looks like from the outside.