feat(audio): implement controlled hw→plughw fallback for ALSA Direct

- Add AlsaDirectError enum for structured error classification
- Add BitPerfectMode enum to track runtime bit-perfect status
- Implement automatic fallback: hw fails with format error → try plughw
- Abort on non-recoverable errors (busy, permissions, invalid params)
- Respect ALSA plugin selection from UI settings
- Log runtime mode for debugging

This allows SMSL-class DACs that fail on hw: to work via plughw:
while maintaining bit-perfect guarantees (format conversion only,
no resampling).

cc
This commit is contained in:
vicrodh committed 2026-02-01 19:13:11 -06:00
1 parent 4670b1548a
commit da5ec2abcb
3 files changed
+170 -12

No files matched your search

+4 -1
View File
@@ -451,7 +451,10 @@ fn try_init_stream_with_backend(
// Downcast backend to AlsaBackend to access try_create_direct_stream
if let Some(alsa_backend) = backend.as_any().downcast_ref::<crate::audio::alsa_backend::AlsaBackend>() {
if let Some(result) = alsa_backend.try_create_direct_stream(&config) {
return Some(result.map(|stream| StreamType::AlsaDirect(Arc::new(stream))));
return Some(result.map(|(stream, mode)| {
log::info!("ALSA Direct stream created with mode: {:?}", mode);
StreamType::AlsaDirect(Arc::new(stream))
}));
}
}
}