refactor: collapse the single-implementation backend abstraction, fix device resolution
isr.py carried a plugin architecture — AudioBackend ABC, a _backend_classes registry, _discover_backends, available_backends/get_backend, a preferred_backend config knob — for exactly one implementation. It was also the source of three real bugs: * find_device() returned None before reaching the ALSA PCM-name fallback whenever `arecord -l` enumerated nothing, so the documented `device = shared_mic` (dsnoop from asound.conf) case failed outright on any host with no hardware card. The fallback is the whole point: those PCMs never appear in `arecord -l`. * `device = monitor` could never resolve. ALSA has no generic monitor source and list_devices hardcoded is_monitor=False, so the keyword — advertised in config.example.ini as the "EASY" way to capture system audio — only ever produced "device not found". Removed; it is a PulseAudio idea that outlived the PulseAudio backend. * list_all_devices() deduplicated by lowercased name "in case a device appears in multiple backends". With one backend what it actually did was delete the second of two identical USB cards. Dedup dropped. find_device() now always returns a device, so _resolve_device's unreachable "Available devices:" error is gone; an unknown spec is passed to ALSA verbatim and logged. AudioDevice loses backend/ is_monitor plus channels/sample_rate — the latter were hardcoded 2/44100 and only ever printed by --list-devices, i.e. numbers with no bearing on what gets recorded. --list-devices now says outright that it lists hardware cards only, which is where the shared_mic confusion started. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -107,7 +107,7 @@ format = wav # wav | flac
|
||||
| `hw:X,Y` | Exact ALSA hardware ID |
|
||||
| `<pcm name>` | Any ALSA PCM defined in `asound.conf` (e.g. the `shared_mic` dsnoop device), even if it doesn't appear in `arecord -l` |
|
||||
|
||||
Run `python isr.py --list-devices` (or `arecord -l`) to see available devices and their IDs.
|
||||
Run `python isr.py --list-devices` (or `arecord -l`) to see available devices and their IDs. It lists **hardware cards only** — a PCM name from `asound.conf` never appears there but can still be used directly, including on hosts where no hardware card is enumerable at all. An unrecognised value is passed to ALSA verbatim, so a typo shows up as an `arecord` error in the log rather than at startup.
|
||||
|
||||
FLAC output requires `pip install soundfile numpy`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user