fix(audio): treat ValueError from format probing as unsupported (raw ALSA devices) - #286
Open
kiwipaulrob wants to merge 1 commit into
Open
kiwipaulrob wants to merge 1 commit into
kiwipaulrob wants to merge 1 commit into
Conversation
PortAudio raises ValueError (not PortAudioError) for device names it does not recognise, e.g. raw ALSA names such as hw:CARD=...,DEV=... . _check_format() only caught PortAudioError, so detect_supported_audio_formats() raised at startup for such devices and the documented raw-ALSA --audio-device form was unusable. Treat it as an unsupported format so the existing safe-default fallback applies. Mirrors the ValueError handling already added to _try_alsa_device() in Sendspin#224.
This branch has not been deployed
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.
Problem
--audio-deviceaccepts raw ALSA names (e.g.hw:CARD=sndrpihifiberry,DEV=0,dmix,plug).resolve_audio_device()handles those through_try_alsa_device(), which — since #224 — treats PortAudio'sValueErroras a lookup miss and validates the name againstaplay -L.The format-detection step that runs afterwards was missed:
_check_format()only catchessounddevice.PortAudioError, while PortAudio raisesValueErrorfor the very same unrecognised names. A device resolved this way hasindex=Noneand only analsa_device_name, sodevice.device_idis that raw name;check_output_settings()therefore raisesValueError, it escapes_check_format(), and it propagates out ofdetect_supported_audio_formats()— the client fails at startup before it ever reaches the server.That is the failure reported in #262 (and the same class as #251): a device listed by
sendspin audio-devices liststill cannot be used.Fix
Catch
ValueErroralongsidePortAudioErrorin_check_format()and report the format as unsupported, exactly as_try_alsa_device()already does on the resolution path.detect_supported_audio_formats()then takes its existing "Could not detect supported formats, using safe defaults" branch, so startup proceeds and the real format is negotiated with the server later.Verification
pytest— 149 passed, including 2 new tests intests/test_audio_devices.py:_check_format()returnsFalse(instead of raising) whencheck_output_settingsraisesValueError;detect_supported_audio_formats()returns non-empty safe defaults for an ALSA-only device.ruff check,ruff format --check,mypy sendspinall clean.Fixes #262
Refs #251