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:
+3
-13
@@ -67,16 +67,14 @@ format = auto
|
||||
#
|
||||
# # Device selection (use one of these methods):
|
||||
# # device = default - Use system default input device
|
||||
# # device = monitor - Auto-select first monitor/loopback source (for system audio)
|
||||
# # device = <name> - Match device by partial name (e.g., "Stereo Mix")
|
||||
# # device = <id> - Use exact device ID from --list-devices
|
||||
# # device = <pcm> - Any ALSA PCM name from asound.conf (e.g. shared_mic);
|
||||
# # these never show up in --list-devices but work anyway
|
||||
# #
|
||||
# # To list available devices, run: python isr.py --list-devices
|
||||
# device = default
|
||||
#
|
||||
# # Audio backend (only 'alsa' is supported):
|
||||
# # backend = alsa
|
||||
#
|
||||
# # Sample rate in Hz (common: 44100, 48000, 96000)
|
||||
# sample_rate = 44100
|
||||
#
|
||||
@@ -122,17 +120,10 @@ format = auto
|
||||
#
|
||||
# Run: python isr.py --list-devices (or: arecord -l) to list devices.
|
||||
#
|
||||
# EASY: Use the "monitor" keyword to capture system/loopback audio:
|
||||
# [system_audio]
|
||||
# type = soundcard
|
||||
# device = monitor
|
||||
# format = wav
|
||||
#
|
||||
# MANUAL: Specify a device by ALSA hardware ID from --list-devices:
|
||||
# Specify a device by ALSA hardware ID from --list-devices:
|
||||
# [usb_mic]
|
||||
# type = soundcard
|
||||
# device = hw:1,0
|
||||
# backend = alsa
|
||||
# sample_rate = 44100
|
||||
# channels = 2
|
||||
# format = flac
|
||||
@@ -148,7 +139,6 @@ format = auto
|
||||
# [usb_mic_shared]
|
||||
# type = soundcard
|
||||
# device = shared_mic
|
||||
# backend = alsa
|
||||
# sample_rate = 48000
|
||||
# channels = 2
|
||||
# format = flac
|
||||
|
||||
Reference in New Issue
Block a user