Repository navigation
fix: give up on an output device that stops taking audio - #84
Merged
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
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.
Cmd+Opt+S in stack-nudge kept doing nothing, turned out the daemon was wedging and getting killed by the watchdog about 6 times a day. Sampled one before it went, the worker was sat in PortAudio's blocking write waiting for buffer space on my USB DAC, with no CoreAudio IO thread left to drain it. Blocking write never gives up so its 60s+ of nothing, then the watchdog kills the daemon and it reloads the model, and in the meantime the queue fills and everything else gets refused.
Now
_writefeeds the stream in slices ofwrite_availableand raisesOutputStalledErrorif the device takes nothing for 5s. The stream gets aborted rather than stopped (stop waits for the queued audio to drain, which never happens) and the daemon resets PortAudio and replays the request once. A second stall goes down the normal playback error path, and the watchdog is still there for the stream stop deadlock. (No idea why the DAC stops pulling, the unified log has nothing for coreaudiod.)Played a sentence through the DAC old vs new, same timing and the same single underflow at stream start, ~550 writes instead of 3 though. Couldn't get the DAC to stall on demand so the stall path is only covered by mocked tests. Downside is a replay starts the utterance from the top, so if it stalls partway you hear the start twice.
456 tests (10 new), ruff and mypy clean.