Fix ALSA device matching for hw:CARD=...,DEV=... format - #224
Merged
Conversation
Catch ValueError (in addition to PortAudioError) from sounddevice.check_output_settings, then validate against the ALSA device list before accepting the device with safe defaults. Fixes #208 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes ALSA device resolution for hw:CARD=...,DEV=...-style names by handling ValueError from sounddevice.check_output_settings, validating against the system ALSA device list, and adding targeted unit tests for _try_alsa_device.
Changes:
- Treat
ValueErrorfromsounddevice.check_output_settings(device=...)as “PortAudio doesn’t recognize the name”, then validate existence viaaplay -Loutput. - Accept ALSA-listed devices with safe default channel/sample-rate values when PortAudio cannot query details.
- Add unit tests covering PortAudio-accepted devices, PortAudio errors, and ALSA-only /
hw:CARD=...,DEV=...scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
sendspin/audio_devices.py |
Expands _try_alsa_device() to handle ValueError and gate acceptance on the ALSA device list. |
tests/test_audio_devices.py |
Adds focused tests for _try_alsa_device() behavior across PortAudio/ALSA matching paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When check_output_settings raises ValueError, _try_alsa_device falls through to query_devices which must also be patched to avoid hitting the real PortAudio backend. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
ValueError(in addition toPortAudioError) fromsounddevice.check_output_settings— PortAudio raisesValueErrorforhw:CARD=...,DEV=...names it doesn't recognize_try_alsa_deviceSimpler alternative to #218 — 6 lines changed in production code vs ~80.
Fixes #208
🤖 Generated with Claude Code